virtuaservices 0.2.0 → 0.3.0
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 +4 -4
- data/lib/virtuaservices/utils/controllers.rb +3 -3
- data/lib/virtuaservices/utils/controllers/base.rb +17 -17
- data/lib/virtuaservices/utils/controllers/checked.rb +2 -2
- data/lib/virtuaservices/utils/errors.rb +5 -5
- data/lib/virtuaservices/utils/errors/bad_request.rb +2 -2
- data/lib/virtuaservices/utils/loaders.rb +2 -2
- data/lib/virtuaservices/utils/loaders/heroku.rb +2 -2
- data/lib/virtuaservices/utils/micro_service.rb +1 -1
- data/lib/virtuaservices/utils/seeder.rb +1 -1
- data/lib/virtuaservices/version.rb +1 -1
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 16488d6c6dd2d6b562f3bd1f1242248a504259acfe3f72d7a07860fae29ca936
|
4
|
+
data.tar.gz: 2903a8b31b10b89e6f09c7dbf834b88210b2dd220e9a1b9771662ee72a224c25
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 993c1bbc126920db2f8111fb1a36f2774598061bbbf84d8e6a7a3737ce189d2f8e8b095b964759b5712f082c58d579e337ef69f6dbd3c90b87518fe44b7b3d07
|
7
|
+
data.tar.gz: ddeac73d2ce9691a08b4b3caad9ba391fe669de661ed88162db2ab2f354c9e9062e80a8326ae9a0fea956c2d4f887ac3ddebead8a942c89965f07124eed7d73d
|
@@ -1,8 +1,8 @@
|
|
1
|
-
module
|
1
|
+
module Virtuaservices
|
2
2
|
module Utils
|
3
3
|
module Controllers
|
4
|
-
autoload :Base , '
|
5
|
-
autoload :Checked, '
|
4
|
+
autoload :Base , 'virtuaservices/utils/controllers/base'
|
5
|
+
autoload :Checked, 'virtuaservices/utils/controllers/checked'
|
6
6
|
end
|
7
7
|
end
|
8
8
|
end
|
@@ -1,4 +1,4 @@
|
|
1
|
-
module
|
1
|
+
module Virtuaservices
|
2
2
|
module Utils
|
3
3
|
module Controllers
|
4
4
|
# Base controller to handle the standard error when accessing the API.
|
@@ -31,15 +31,15 @@ module Arkaan
|
|
31
31
|
# @param path [String] the path, beginning with a /, of the route to create.
|
32
32
|
# @param premium [Boolean] TRUE to make the route premium, FALSE otherwise.
|
33
33
|
def self.declare_route_with(verb, path, premium, options, &block)
|
34
|
-
service =
|
35
|
-
complete_path = "#{
|
34
|
+
service = Virtuaservices::Utils::MicroService.instance.service
|
35
|
+
complete_path = "#{Virtuaservices::Utils::MicroService.instance.path}#{path == '/' ? '' : path}"
|
36
36
|
|
37
37
|
unless service.nil? || !service.routes.where(path: path, verb: verb).first.nil?
|
38
|
-
route =
|
38
|
+
route = Virtuaservices::Monitoring::Route.create(path: path, verb: verb, premium: premium, service: service)
|
39
39
|
if !options.nil? && !options[:authenticated].nil?
|
40
40
|
route.update_attribute(:authenticated, false)
|
41
41
|
end
|
42
|
-
|
42
|
+
Virtuaservices::Permissions::Group.where(is_superuser: true).each do |group|
|
43
43
|
group.routes << route
|
44
44
|
group.save!
|
45
45
|
end
|
@@ -69,8 +69,8 @@ module Arkaan
|
|
69
69
|
|
70
70
|
check_presence('token', 'app_key', route: 'common')
|
71
71
|
|
72
|
-
gateway =
|
73
|
-
@application =
|
72
|
+
gateway = Virtuaservices::Monitoring::Gateway.where(token: params['token']).first
|
73
|
+
@application = Virtuaservices::OAuth::Application.where(key: params['app_key']).first
|
74
74
|
|
75
75
|
if gateway.nil?
|
76
76
|
custom_error(404, 'common.token.unknown')
|
@@ -101,10 +101,10 @@ module Arkaan
|
|
101
101
|
|
102
102
|
# Checks if the session ID is given in the parameters and if the session exists.
|
103
103
|
# @param action [String] the action used to get the errors from the errors file.
|
104
|
-
# @return [
|
104
|
+
# @return [Virtuaservices::Authentication::Session] the session when it exists.
|
105
105
|
def check_session(action)
|
106
106
|
check_presence('session_id', route: action)
|
107
|
-
session =
|
107
|
+
session = Virtuaservices::Authentication::Session.where(token: params['session_id']).first
|
108
108
|
if session.nil?
|
109
109
|
custom_error(404, "#{action}.session_id.unknown")
|
110
110
|
end
|
@@ -113,7 +113,7 @@ module Arkaan
|
|
113
113
|
|
114
114
|
def check_application(action)
|
115
115
|
check_presence('app_key', route: action)
|
116
|
-
application =
|
116
|
+
application = Virtuaservices::OAuth::Application.where(key: params['app_key']).first
|
117
117
|
custom_error(404, "#{action}.app_key.unknown") if application.nil?
|
118
118
|
return application
|
119
119
|
end
|
@@ -131,10 +131,10 @@ module Arkaan
|
|
131
131
|
end
|
132
132
|
|
133
133
|
# Gets the current route in the database from the sinatra route.
|
134
|
-
# @return [
|
134
|
+
# @return [Virtuaservices::Monitoring::Route] the route declared in the services registry.
|
135
135
|
def parse_current_route
|
136
136
|
splitted = request.env['sinatra.route'].split(' ')
|
137
|
-
return
|
137
|
+
return Virtuaservices::Monitoring::Route.where(verb: splitted.first.downcase, path: splitted.last).first
|
138
138
|
end
|
139
139
|
|
140
140
|
# Halts the application and creates the returned body from the parameters and the errors config file.
|
@@ -162,25 +162,25 @@ module Arkaan
|
|
162
162
|
return params.select { |key, value| fields.include?(key) }
|
163
163
|
end
|
164
164
|
|
165
|
-
# Creates a custom error from an existing
|
165
|
+
# Creates a custom error from an existing Virtuaservices exception class.
|
166
166
|
# @param exception {StandardError} the exception to transform in a usable error.
|
167
167
|
def handle_arkaan_exception(exception)
|
168
168
|
custom_error(exception.status, "#{exception.action}.#{exception.field}.#{exception.error}")
|
169
169
|
end
|
170
170
|
|
171
|
-
error
|
171
|
+
error Virtuaservices::Utils::Errors::BadRequest do |exception|
|
172
172
|
handle_arkaan_exception(exception)
|
173
173
|
end
|
174
174
|
|
175
|
-
error
|
175
|
+
error Virtuaservices::Utils::Errors::Forbidden do |exception|
|
176
176
|
handle_arkaan_exception(exception)
|
177
177
|
end
|
178
178
|
|
179
|
-
error
|
179
|
+
error Virtuaservices::Utils::Errors::NotFound do |exception|
|
180
180
|
handle_arkaan_exception(exception)
|
181
181
|
end
|
182
182
|
|
183
|
-
error
|
183
|
+
error Virtuaservices::Factories::Errors::GatewayNotFound do |exception|
|
184
184
|
handle_arkaan_exception(exception)
|
185
185
|
end
|
186
186
|
|
@@ -1,9 +1,9 @@
|
|
1
|
-
module
|
1
|
+
module Virtuaservices
|
2
2
|
module Utils
|
3
3
|
module Controllers
|
4
4
|
# Base controller to handle the standard error when accessing the API.
|
5
5
|
# @author Vincent Courtois <courtois.vincenet@outlook.com>
|
6
|
-
class Checked <
|
6
|
+
class Checked < Virtuaservices::Utils::Controllers::Base
|
7
7
|
|
8
8
|
before do
|
9
9
|
before_checks
|
@@ -1,12 +1,12 @@
|
|
1
|
-
module
|
1
|
+
module Virtuaservices
|
2
2
|
module Utils
|
3
3
|
# Module gathering all the exception classes used throughout the utils module, mainly linked to HTTP errors.
|
4
4
|
# @author Vincent Courtois <courtois.vincent@outlook.com>
|
5
5
|
module Errors
|
6
|
-
autoload :BadRequest, '
|
7
|
-
autoload :Forbidden , '
|
8
|
-
autoload :NotFound , '
|
9
|
-
autoload :HTTPError , '
|
6
|
+
autoload :BadRequest, 'virtuaservices/utils/errors/bad_request'
|
7
|
+
autoload :Forbidden , 'virtuaservices/utils/errors/forbidden'
|
8
|
+
autoload :NotFound , 'virtuaservices/utils/errors/not_found'
|
9
|
+
autoload :HTTPError , 'virtuaservices/utils/errors/http_error'
|
10
10
|
end
|
11
11
|
end
|
12
12
|
end
|
@@ -1,9 +1,9 @@
|
|
1
|
-
module
|
1
|
+
module Virtuaservices
|
2
2
|
module Utils
|
3
3
|
module Errors
|
4
4
|
# A bad request error is raised when the data given to a model makes this model invalid.
|
5
5
|
# @author Vincent Courtois <courtois.vincent@outlook.com>
|
6
|
-
class BadRequest <
|
6
|
+
class BadRequest < Virtuaservices::Utils::Errors::HTTPError
|
7
7
|
|
8
8
|
def initialize(action:, field:, error:)
|
9
9
|
super(action, field, error, 400)
|
@@ -1,9 +1,9 @@
|
|
1
|
-
module
|
1
|
+
module Virtuaservices
|
2
2
|
module Utils
|
3
3
|
module Plugins
|
4
4
|
class Heroku
|
5
5
|
# Loads the heroku informations inside the data of the instance.
|
6
|
-
# @param instance [
|
6
|
+
# @param instance [Virtuaservices::Monitoring::Instance] the instance to put the enrichment inside.
|
7
7
|
def self.load!(instance)
|
8
8
|
if !ENV['OAUTH_TOKEN'].nil? && instance != false && instance.persisted?
|
9
9
|
heroku = PlatformAPI.connect_oauth(ENV['OAUTH_TOKEN'])
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: virtuaservices
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.
|
4
|
+
version: 0.3.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Vincent Courtois
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2019-07-
|
11
|
+
date: 2019-07-09 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: rspec
|