qas_dock_gem 0.1.29 → 0.1.30
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/.gitignore +1 -0
- data/CODE_OF_CONDUCT.md +39 -21
- data/Gemfile +2 -2
- data/Gemfile.lock +6 -6
- data/README.md +13 -5
- data/lib/qas_dock_gem.rb +107 -99
- data/lib/qas_dock_gem/services/aws_services.rb +22 -20
- data/lib/qas_dock_gem/services/redis_services.rb +45 -55
- data/lib/qas_dock_gem/version.rb +1 -1
- data/qas_dock_gem.gemspec +18 -18
- metadata +9 -9
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 0e5f0f121b13f8dc6d1106ea9cb4126ed4c182d795aa8d999c15bcb2df377fd0
|
4
|
+
data.tar.gz: 2c058ba1910dc842b97af337a8d3d59ed871d55d485f0e854d5b775ec8e96a80
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: d05f85e1d2e38f66056a0ea9dde29423214112e2e13d8408de310d91d2ae84785f714eaacb9d9aa0e0c041887c9a81c36e0a313dbbc462a930726f3c40370ee3
|
7
|
+
data.tar.gz: 3ee52b6c7a0ed6d5ddba204e9b62acff83506ffae77c7975ddc4191ec75dfda556b356c8b16661241a80bf07486dba7a8b4a947feac9dbaf34487e23b5e92e25
|
data/.gitignore
CHANGED
data/CODE_OF_CONDUCT.md
CHANGED
@@ -2,7 +2,10 @@
|
|
2
2
|
|
3
3
|
## Our Pledge
|
4
4
|
|
5
|
-
We as members, contributors, and leaders pledge to make participation in our community a harassment-free experience for
|
5
|
+
We as members, contributors, and leaders pledge to make participation in our community a harassment-free experience for
|
6
|
+
everyone, regardless of age, body size, visible or invisible disability, ethnicity, sex characteristics, gender identity
|
7
|
+
and expression, level of experience, education, socio-economic status, nationality, personal appearance, race, religion,
|
8
|
+
or sexual identity and orientation.
|
6
9
|
|
7
10
|
We pledge to act and interact in ways that contribute to an open, welcoming, diverse, inclusive, and healthy community.
|
8
11
|
|
@@ -18,67 +21,82 @@ Examples of behavior that contributes to a positive environment for our communit
|
|
18
21
|
|
19
22
|
Examples of unacceptable behavior include:
|
20
23
|
|
21
|
-
* The use of sexualized language or imagery, and sexual attention or
|
22
|
-
advances of any kind
|
24
|
+
* The use of sexualized language or imagery, and sexual attention or advances of any kind
|
23
25
|
* Trolling, insulting or derogatory comments, and personal or political attacks
|
24
26
|
* Public or private harassment
|
25
|
-
* Publishing others' private information, such as a physical or email
|
26
|
-
|
27
|
-
* Other conduct which could reasonably be considered inappropriate in a
|
28
|
-
professional setting
|
27
|
+
* Publishing others' private information, such as a physical or email address, without their explicit permission
|
28
|
+
* Other conduct which could reasonably be considered inappropriate in a professional setting
|
29
29
|
|
30
30
|
## Enforcement Responsibilities
|
31
31
|
|
32
|
-
Community leaders are responsible for clarifying and enforcing our standards of acceptable behavior and will take
|
32
|
+
Community leaders are responsible for clarifying and enforcing our standards of acceptable behavior and will take
|
33
|
+
appropriate and fair corrective action in response to any behavior that they deem inappropriate, threatening, offensive,
|
34
|
+
or harmful.
|
33
35
|
|
34
|
-
Community leaders have the right and responsibility to remove, edit, or reject comments, commits, code, wiki edits,
|
36
|
+
Community leaders have the right and responsibility to remove, edit, or reject comments, commits, code, wiki edits,
|
37
|
+
issues, and other contributions that are not aligned to this Code of Conduct, and will communicate reasons for
|
38
|
+
moderation decisions when appropriate.
|
35
39
|
|
36
40
|
## Scope
|
37
41
|
|
38
|
-
This Code of Conduct applies within all community spaces, and also applies when an individual is officially representing
|
42
|
+
This Code of Conduct applies within all community spaces, and also applies when an individual is officially representing
|
43
|
+
the community in public spaces. Examples of representing our community include using an official e-mail address, posting
|
44
|
+
via an official social media account, or acting as an appointed representative at an online or offline event.
|
39
45
|
|
40
46
|
## Enforcement
|
41
47
|
|
42
|
-
Instances of abusive, harassing, or otherwise unacceptable behavior may be reported to the community leaders responsible
|
48
|
+
Instances of abusive, harassing, or otherwise unacceptable behavior may be reported to the community leaders responsible
|
49
|
+
for enforcement at lucas.gimenes23@gmail.com. All complaints will be reviewed and investigated promptly and fairly.
|
43
50
|
|
44
51
|
All community leaders are obligated to respect the privacy and security of the reporter of any incident.
|
45
52
|
|
46
53
|
## Enforcement Guidelines
|
47
54
|
|
48
|
-
Community leaders will follow these Community Impact Guidelines in determining the consequences for any action they deem
|
55
|
+
Community leaders will follow these Community Impact Guidelines in determining the consequences for any action they deem
|
56
|
+
in violation of this Code of Conduct:
|
49
57
|
|
50
58
|
### 1. Correction
|
51
59
|
|
52
|
-
**Community Impact**: Use of inappropriate language or other behavior deemed unprofessional or unwelcome in the
|
60
|
+
**Community Impact**: Use of inappropriate language or other behavior deemed unprofessional or unwelcome in the
|
61
|
+
community.
|
53
62
|
|
54
|
-
**Consequence**: A private, written warning from community leaders, providing clarity around the nature of the violation
|
63
|
+
**Consequence**: A private, written warning from community leaders, providing clarity around the nature of the violation
|
64
|
+
and an explanation of why the behavior was inappropriate. A public apology may be requested.
|
55
65
|
|
56
66
|
### 2. Warning
|
57
67
|
|
58
68
|
**Community Impact**: A violation through a single incident or series of actions.
|
59
69
|
|
60
|
-
**Consequence**: A warning with consequences for continued behavior. No interaction with the people involved, including
|
70
|
+
**Consequence**: A warning with consequences for continued behavior. No interaction with the people involved, including
|
71
|
+
unsolicited interaction with those enforcing the Code of Conduct, for a specified period of time. This includes avoiding
|
72
|
+
interactions in community spaces as well as external channels like social media. Violating these terms may lead to a
|
73
|
+
temporary or permanent ban.
|
61
74
|
|
62
75
|
### 3. Temporary Ban
|
63
76
|
|
64
77
|
**Community Impact**: A serious violation of community standards, including sustained inappropriate behavior.
|
65
78
|
|
66
|
-
**Consequence**: A temporary ban from any sort of interaction or public communication with the community for a specified
|
79
|
+
**Consequence**: A temporary ban from any sort of interaction or public communication with the community for a specified
|
80
|
+
period of time. No public or private interaction with the people involved, including unsolicited interaction with those
|
81
|
+
enforcing the Code of Conduct, is allowed during this period. Violating these terms may lead to a permanent ban.
|
67
82
|
|
68
83
|
### 4. Permanent Ban
|
69
84
|
|
70
|
-
**Community Impact**: Demonstrating a pattern of violation of community standards, including sustained inappropriate
|
85
|
+
**Community Impact**: Demonstrating a pattern of violation of community standards, including sustained inappropriate
|
86
|
+
behavior, harassment of an individual, or aggression toward or disparagement of classes of individuals.
|
71
87
|
|
72
88
|
**Consequence**: A permanent ban from any sort of public interaction within the community.
|
73
89
|
|
74
90
|
## Attribution
|
75
91
|
|
76
|
-
This Code of Conduct is adapted from the [Contributor Covenant][homepage], version 2.0,
|
77
|
-
|
92
|
+
This Code of Conduct is adapted from the [Contributor Covenant][homepage], version 2.0, available
|
93
|
+
at https://www.contributor-covenant.org/version/2/0/code_of_conduct.html.
|
78
94
|
|
79
|
-
Community Impact Guidelines were inspired
|
95
|
+
Community Impact Guidelines were inspired
|
96
|
+
by [Mozilla's code of conduct enforcement ladder](https://github.com/mozilla/diversity).
|
80
97
|
|
81
98
|
[homepage]: https://www.contributor-covenant.org
|
82
99
|
|
83
100
|
For answers to common questions about this code of conduct, see the FAQ at
|
84
|
-
https://www.contributor-covenant.org/faq. Translations are available
|
101
|
+
https://www.contributor-covenant.org/faq. Translations are available
|
102
|
+
at https://www.contributor-covenant.org/translations.
|
data/Gemfile
CHANGED
data/Gemfile.lock
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
PATH
|
2
2
|
remote: .
|
3
3
|
specs:
|
4
|
-
qas_dock_gem (0.1.
|
4
|
+
qas_dock_gem (0.1.30)
|
5
5
|
|
6
6
|
GEM
|
7
7
|
remote: https://rubygems.org/
|
8
8
|
specs:
|
9
9
|
aws-eventstream (1.1.1)
|
10
|
-
aws-partitions (1.
|
11
|
-
aws-sdk-core (3.
|
10
|
+
aws-partitions (1.441.0)
|
11
|
+
aws-sdk-core (3.113.1)
|
12
12
|
aws-eventstream (~> 1, >= 1.0.2)
|
13
13
|
aws-partitions (~> 1, >= 1.239.0)
|
14
14
|
aws-sigv4 (~> 1.1)
|
@@ -22,7 +22,7 @@ GEM
|
|
22
22
|
mime-types (~> 3.0)
|
23
23
|
multi_xml (>= 0.5.2)
|
24
24
|
jmespath (1.4.0)
|
25
|
-
logger (1.4.
|
25
|
+
logger (1.4.2)
|
26
26
|
mime-types (3.3.1)
|
27
27
|
mime-types-data (~> 3.2015)
|
28
28
|
mime-types-data (3.2021.0225)
|
@@ -31,7 +31,7 @@ GEM
|
|
31
31
|
redis (4.2.5)
|
32
32
|
|
33
33
|
PLATFORMS
|
34
|
-
x86_64-linux
|
34
|
+
x86_64-linux
|
35
35
|
|
36
36
|
DEPENDENCIES
|
37
37
|
aws-sdk-secretsmanager
|
@@ -43,4 +43,4 @@ DEPENDENCIES
|
|
43
43
|
redis
|
44
44
|
|
45
45
|
BUNDLED WITH
|
46
|
-
2.2.
|
46
|
+
2.2.15
|
data/README.md
CHANGED
@@ -1,6 +1,8 @@
|
|
1
1
|
# QasDockGem
|
2
2
|
|
3
|
-
Welcome to your new gem! In this directory, you'll find the files you need to be able to package up your Ruby library
|
3
|
+
Welcome to your new gem! In this directory, you'll find the files you need to be able to package up your Ruby library
|
4
|
+
into a gem. Put your Ruby code in the file `lib/qas_dock_gem`. To experiment with that code, run `bin/console` for an
|
5
|
+
interactive prompt.
|
4
6
|
|
5
7
|
TODO: Delete this and the text above, and describe your gem
|
6
8
|
|
@@ -26,13 +28,18 @@ TODO: Write usage instructions here
|
|
26
28
|
|
27
29
|
## Development
|
28
30
|
|
29
|
-
After checking out the repo, run `bin/setup` to install dependencies. You can also run `bin/console` for an interactive
|
31
|
+
After checking out the repo, run `bin/setup` to install dependencies. You can also run `bin/console` for an interactive
|
32
|
+
prompt that will allow you to experiment.
|
30
33
|
|
31
|
-
To install this gem onto your local machine, run `bundle exec rake install`. To release a new version, update the
|
34
|
+
To install this gem onto your local machine, run `bundle exec rake install`. To release a new version, update the
|
35
|
+
version number in `version.rb`, and then run `bundle exec rake release`, which will create a git tag for the version,
|
36
|
+
push git commits and the created tag, and push the `.gem` file to [rubygems.org](https://rubygems.org).
|
32
37
|
|
33
38
|
## Contributing
|
34
39
|
|
35
|
-
Bug reports and pull requests are welcome on GitHub at https://github.com/[USERNAME]/qas_dock_gem. This project is
|
40
|
+
Bug reports and pull requests are welcome on GitHub at https://github.com/[USERNAME]/qas_dock_gem. This project is
|
41
|
+
intended to be a safe, welcoming space for collaboration, and contributors are expected to adhere to
|
42
|
+
the [code of conduct](https://github.com/[USERNAME]/qas_dock_gem/blob/master/CODE_OF_CONDUCT.md).
|
36
43
|
|
37
44
|
## License
|
38
45
|
|
@@ -40,4 +47,5 @@ The gem is available as open source under the terms of the [MIT License](https:/
|
|
40
47
|
|
41
48
|
## Code of Conduct
|
42
49
|
|
43
|
-
Everyone interacting in the QasDockGem project's codebases, issue trackers, chat rooms and mailing lists is expected to
|
50
|
+
Everyone interacting in the QasDockGem project's codebases, issue trackers, chat rooms and mailing lists is expected to
|
51
|
+
follow the [code of conduct](https://github.com/[USERNAME]/qas_dock_gem/blob/master/CODE_OF_CONDUCT.md).
|
data/lib/qas_dock_gem.rb
CHANGED
@@ -1,119 +1,127 @@
|
|
1
1
|
# frozen_string_literal: true
|
2
2
|
|
3
|
-
require_relative
|
4
|
-
require_relative
|
5
|
-
require_relative
|
3
|
+
require_relative 'qas_dock_gem/version'
|
4
|
+
require_relative 'qas_dock_gem/services/aws_services'
|
5
|
+
require_relative 'qas_dock_gem/services/redis_services'
|
6
6
|
|
7
7
|
module QasDockGem
|
8
8
|
class RequestsAPI
|
9
|
-
|
10
|
-
|
11
|
-
def initialize
|
12
|
-
require "logger"
|
13
|
-
@logger = Logger.new(STDOUT)
|
14
|
-
end
|
15
|
-
|
16
|
-
def initialize_headers(token, headers)
|
17
|
-
headers_default = {"cache-control": "no-cache", "content-type": "application/json"}
|
18
|
-
|
19
|
-
#seta o campo authorization caso o token seja diferente de nulo
|
20
|
-
headers_default["Authorization"] = token unless token.nil?
|
21
|
-
|
22
|
-
#define os headers parametrizados como um Hash caso seja nulo
|
23
|
-
headers = {} if headers.nil?
|
9
|
+
require 'httparty'
|
24
10
|
|
25
|
-
|
26
|
-
|
11
|
+
def initialize
|
12
|
+
require 'logger'
|
13
|
+
@logger = Logger.new($stdout)
|
14
|
+
end
|
27
15
|
|
28
|
-
|
29
|
-
|
30
|
-
|
31
|
-
#retorna os headers
|
32
|
-
JSON.parse(headers_default.to_json)
|
33
|
-
end
|
34
|
-
|
35
|
-
def initialize_request(params)
|
36
|
-
formated_params = init_request_body(params[:token], params[:payload], params[:headers]) if params.include?(:payload)
|
37
|
-
formated_params = init_request_query(params[:token], params[:query], params[:headers]) if params.include?(:query)
|
38
|
-
formated_params = init_request_basic_auth(params[:token], params[:basic_auth], params[:headers]) if params.include?(:basic_auth)
|
16
|
+
def initialize_headers(token, headers)
|
17
|
+
headers_default = { "cache-control": 'no-cache', "content-type": 'application/json' }
|
39
18
|
|
40
|
-
|
41
|
-
|
42
|
-
end
|
19
|
+
# seta o campo authorization caso o token seja diferente de nulo
|
20
|
+
headers_default['Authorization'] = token unless token.nil?
|
43
21
|
|
44
|
-
|
45
|
-
|
46
|
-
payload = {} if payload.nil?
|
47
|
-
@logger.info("Payload: #{payload.to_json}")
|
48
|
-
@logger.info("Headers: #{final_headers}")
|
22
|
+
# define os headers parametrizados como um Hash caso seja nulo
|
23
|
+
headers = {} if headers.nil?
|
49
24
|
|
50
|
-
|
51
|
-
|
25
|
+
# realiza o merge dos headers defaults + os headers parametrizados
|
26
|
+
headers_default.merge!(headers)
|
52
27
|
|
53
|
-
|
54
|
-
|
55
|
-
|
56
|
-
@logger.info("Headers: #{final_headers}")
|
57
|
-
{ :headers => final_headers, :basic_auth => basic_auth }
|
28
|
+
# remove o campo content-type caso não seja informado
|
29
|
+
if (headers_default[:"content-type"] == '') || headers_default[:"content-type"].nil?
|
30
|
+
headers_default.delete(:"content-type")
|
58
31
|
end
|
59
32
|
|
60
|
-
|
61
|
-
|
62
|
-
|
63
|
-
@logger.info("Query: #{query}")
|
64
|
-
@logger.info("Headers: #{final_headers}")
|
65
|
-
|
66
|
-
{ :headers => final_headers, :query => query }
|
67
|
-
end
|
68
|
-
|
69
|
-
def execute_post(params)
|
70
|
-
formated_params = initialize_request(params)
|
71
|
-
@logger.info("Realizando POST")
|
72
|
-
@logger.info("URI: #{params[:uri]}")
|
73
|
-
request = HTTParty.post(params[:uri], formated_params)
|
74
|
-
@logger.info("URI Final: #{request.request.last_uri}")
|
75
|
-
@logger.info("POST realizado \n")
|
76
|
-
request
|
77
|
-
end
|
33
|
+
# retorna os headers
|
34
|
+
JSON.parse(headers_default.to_json)
|
35
|
+
end
|
78
36
|
|
79
|
-
|
80
|
-
|
81
|
-
|
82
|
-
|
83
|
-
request = HTTParty.get(params[:uri], formated_params)
|
84
|
-
@logger.info("URI Final: #{request.request.last_uri}")
|
85
|
-
@logger.info("GET realizado \n")
|
86
|
-
request
|
37
|
+
def initialize_request(params)
|
38
|
+
formated_params = nil
|
39
|
+
if params.include?(:payload)
|
40
|
+
formated_params = init_request_body(params[:token], params[:payload], params[:headers])
|
87
41
|
end
|
88
42
|
|
89
|
-
|
90
|
-
formated_params = initialize_request(params)
|
91
|
-
@logger.info("Realizando PATCH")
|
92
|
-
@logger.info("URI: #{params[:uri]}")
|
93
|
-
request = HTTParty.patch(params[:uri], formated_params)
|
94
|
-
@logger.info("URI Final: #{request.request.last_uri}")
|
95
|
-
@logger.info("PATCH realizado \n")
|
96
|
-
request
|
97
|
-
end
|
43
|
+
formated_params = init_request_query(params[:token], params[:query], params[:headers]) if params.include?(:query)
|
98
44
|
|
99
|
-
|
100
|
-
formated_params =
|
101
|
-
@logger.info("Realizando PUT")
|
102
|
-
@logger.info("URI: #{params[:uri]}")
|
103
|
-
request = HTTParty.put(params[:uri], formated_params)
|
104
|
-
@logger.info("URI Final: #{request.request.last_uri}")
|
105
|
-
@logger.info("PUT realizado \n")
|
106
|
-
request
|
45
|
+
if params.include?(:basic_auth)
|
46
|
+
formated_params = init_request_basic_auth(params[:token], params[:basic_auth], params[:headers])
|
107
47
|
end
|
108
48
|
|
109
|
-
|
110
|
-
|
111
|
-
|
112
|
-
|
113
|
-
|
114
|
-
|
115
|
-
|
116
|
-
|
117
|
-
|
49
|
+
# retorna os params formatados para a request
|
50
|
+
formated_params
|
51
|
+
end
|
52
|
+
|
53
|
+
def init_request_body(token, payload, headers)
|
54
|
+
final_headers = initialize_headers(token, headers)
|
55
|
+
payload = {} if payload.nil?
|
56
|
+
@logger.info("Payload: #{payload.to_json}")
|
57
|
+
@logger.info("Headers: #{final_headers}")
|
58
|
+
|
59
|
+
{ headers: final_headers, body: payload.to_json }
|
60
|
+
end
|
61
|
+
|
62
|
+
def init_request_basic_auth(token, basic_auth, headers)
|
63
|
+
final_headers = initialize_headers(token, headers)
|
64
|
+
@logger.info("Headers: #{final_headers}")
|
65
|
+
{ headers: final_headers, basic_auth: basic_auth }
|
66
|
+
end
|
67
|
+
|
68
|
+
def init_request_query(token, query, headers)
|
69
|
+
final_headers = initialize_headers(token, headers)
|
70
|
+
query = {} if query.nil?
|
71
|
+
@logger.info("Query: #{query}")
|
72
|
+
@logger.info("Headers: #{final_headers}")
|
73
|
+
|
74
|
+
{ headers: final_headers, query: query }
|
75
|
+
end
|
76
|
+
|
77
|
+
def execute_post(params)
|
78
|
+
formated_params = initialize_request(params)
|
79
|
+
@logger.info('Realizando POST')
|
80
|
+
@logger.info("URI: #{params[:uri]}")
|
81
|
+
request = HTTParty.post(params[:uri], formated_params)
|
82
|
+
@logger.info("URI Final: #{request.request.last_uri}")
|
83
|
+
@logger.info("POST realizado \n")
|
84
|
+
request
|
85
|
+
end
|
86
|
+
|
87
|
+
def execute_get(params)
|
88
|
+
formated_params = initialize_request(params)
|
89
|
+
@logger.info('Realizando GET')
|
90
|
+
@logger.info("URI: #{params[:uri]}")
|
91
|
+
request = HTTParty.get(params[:uri], formated_params)
|
92
|
+
@logger.info("URI Final: #{request.request.last_uri}")
|
93
|
+
@logger.info("GET realizado \n")
|
94
|
+
request
|
95
|
+
end
|
96
|
+
|
97
|
+
def execute_patch(params)
|
98
|
+
formated_params = initialize_request(params)
|
99
|
+
@logger.info('Realizando PATCH')
|
100
|
+
@logger.info("URI: #{params[:uri]}")
|
101
|
+
request = HTTParty.patch(params[:uri], formated_params)
|
102
|
+
@logger.info("URI Final: #{request.request.last_uri}")
|
103
|
+
@logger.info("PATCH realizado \n")
|
104
|
+
request
|
105
|
+
end
|
106
|
+
|
107
|
+
def execute_put(params)
|
108
|
+
formated_params = initialize_request(params)
|
109
|
+
@logger.info('Realizando PUT')
|
110
|
+
@logger.info("URI: #{params[:uri]}")
|
111
|
+
request = HTTParty.put(params[:uri], formated_params)
|
112
|
+
@logger.info("URI Final: #{request.request.last_uri}")
|
113
|
+
@logger.info("PUT realizado \n")
|
114
|
+
request
|
115
|
+
end
|
116
|
+
|
117
|
+
def execute_delete(params)
|
118
|
+
formated_params = initialize_request(params)
|
119
|
+
@logger.info('Realizando DELETE')
|
120
|
+
@logger.info("URI: #{params[:uri]}")
|
121
|
+
request = HTTParty.put(params[:uri], formated_params)
|
122
|
+
@logger.info("URI Final: #{request.request.last_uri}")
|
123
|
+
@logger.info("DELETE realizado \n")
|
124
|
+
request
|
125
|
+
end
|
118
126
|
end
|
119
|
-
end
|
127
|
+
end
|
@@ -1,21 +1,23 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
1
3
|
module QasDockGem
|
2
|
-
|
3
|
-
|
4
|
-
|
5
|
-
|
6
|
-
|
7
|
-
|
8
|
-
|
9
|
-
|
10
|
-
|
11
|
-
|
12
|
-
|
13
|
-
|
14
|
-
|
15
|
-
|
16
|
-
|
17
|
-
|
18
|
-
|
19
|
-
|
20
|
-
|
21
|
-
end
|
4
|
+
class AwsServices
|
5
|
+
def credentials_aws(access_key_id, secret_access_key_id, region)
|
6
|
+
{
|
7
|
+
access_key_id: access_key_id,
|
8
|
+
secret_access_key: secret_access_key_id,
|
9
|
+
region: region
|
10
|
+
}
|
11
|
+
end
|
12
|
+
|
13
|
+
def init_secrets_manager(credentials)
|
14
|
+
require 'aws-sdk-secretsmanager'
|
15
|
+
Aws::SecretsManager::Client.new(credentials)
|
16
|
+
end
|
17
|
+
|
18
|
+
def get_sm_secret_value(credentials, secret_name)
|
19
|
+
secret = init_secrets_manager(credentials).get_secret_value(secret_id: secret_name.to_s)
|
20
|
+
JSON.parse(secret.secret_string)
|
21
|
+
end
|
22
|
+
end
|
23
|
+
end
|
@@ -1,57 +1,47 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
1
3
|
module QasDockGem
|
2
|
-
|
3
|
-
|
4
|
-
|
5
|
-
|
6
|
-
|
7
|
-
|
8
|
-
|
9
|
-
|
10
|
-
|
11
|
-
|
12
|
-
|
13
|
-
|
14
|
-
|
15
|
-
|
16
|
-
|
17
|
-
|
18
|
-
|
19
|
-
#Realiza a tentativa de conexão com o redis com os params informados
|
20
|
-
@redis = Redis.new(params_redis)
|
21
|
-
begin
|
22
|
-
#verifica se a conexão obteve sucesso
|
23
|
-
@redis.ping
|
24
|
-
#caso tenha obtido sucesso na conexão, retorna o objeto do Redis
|
25
|
-
return @redis
|
26
|
-
rescue StandardError => redis_exception
|
27
|
-
@redis = nil
|
28
|
-
@logger.error("Params Redis: #{JSON.pretty_generate(JSON.parse(params_redis.to_json))}")
|
29
|
-
@logger.error("Exceção retornada do Redis: #{redis_exception.inspect}")
|
30
|
-
@logger.error("Mensagem de exceção retornada do Redis: #{redis_exception.message}")
|
31
|
-
end
|
32
|
-
end
|
33
|
-
|
34
|
-
def get_key_redis(key)
|
35
|
-
@logger.info("Buscando chave #{key} no Redis")
|
36
|
-
@redis = initialize_redis if @redis.nil?
|
37
|
-
begin
|
38
|
-
@redis.get(key)
|
39
|
-
rescue => redis_excep_get
|
40
|
-
@logger.error("Exceção retornada do redis ao consultar a chave: #{redis_excep_get}")
|
41
|
-
return nil
|
42
|
-
end
|
43
|
-
end
|
44
|
-
|
45
|
-
def set_key_redis(key, value, ttl)
|
46
|
-
@logger.info("Cadastrando chave #{key} com valor: #{value} e tempo de duração: #{ttl}")
|
47
|
-
@redis = initialize_redis if @redis.nil?
|
48
|
-
begin
|
49
|
-
set_redis = @redis.set(key, value, ex: ttl)
|
50
|
-
@logger.info("Chave cadastrada com sucesso no redis") if set_redis == "OK"
|
51
|
-
rescue => redis_excep_set
|
52
|
-
@logger.error("Exceção retornada do redis ao cadastrar a chave: #{redis_excep_set}")
|
53
|
-
return nil
|
54
|
-
end
|
55
|
-
end
|
4
|
+
class RedisService
|
5
|
+
def initialize
|
6
|
+
require 'logger'
|
7
|
+
require 'redis'
|
8
|
+
@logger = Logger.new($stdout)
|
9
|
+
end
|
10
|
+
|
11
|
+
def initialize_redis
|
12
|
+
redis_params = { host: ENV['uri_redis'], port: 6379, connect_timeout: 0.5, read_timeout: 1.0, write_timeout: 1.0 }
|
13
|
+
@redis = Redis.new(redis_params) # Realiza a tentativa de conexão com o redis com os params informados
|
14
|
+
begin
|
15
|
+
@redis.ping
|
16
|
+
@redis
|
17
|
+
rescue StandardError => e
|
18
|
+
@redis = nil
|
19
|
+
@logger.error("Params Redis: #{JSON.pretty_generate(JSON.parse(redis_params.to_json))}")
|
20
|
+
@logger.error("Exceção retornada do Redis: #{e.inspect} - Mensagem: #{e.message}")
|
56
21
|
end
|
57
|
-
end
|
22
|
+
end
|
23
|
+
|
24
|
+
def get_key_redis(key)
|
25
|
+
@logger.info("Buscando chave #{key} no Redis")
|
26
|
+
@redis = initialize_redis if @redis.nil?
|
27
|
+
begin
|
28
|
+
@redis.get(key)
|
29
|
+
rescue StandardError => e
|
30
|
+
@logger.error("Exceção retornada do redis ao consultar a chave: #{e}")
|
31
|
+
nil
|
32
|
+
end
|
33
|
+
end
|
34
|
+
|
35
|
+
def set_key_redis(key, value, ttl)
|
36
|
+
@logger.info("Cadastrando chave #{key} com valor: #{value} e tempo de duração: #{ttl}")
|
37
|
+
@redis = initialize_redis if @redis.nil?
|
38
|
+
begin
|
39
|
+
set_redis = @redis.set(key, value, ex: ttl)
|
40
|
+
@logger.info('Chave cadastrada com sucesso no redis') if set_redis == 'OK'
|
41
|
+
rescue StandardError => e
|
42
|
+
@logger.error("Exceção retornada do redis ao cadastrar a chave: #{e}")
|
43
|
+
nil
|
44
|
+
end
|
45
|
+
end
|
46
|
+
end
|
47
|
+
end
|
data/lib/qas_dock_gem/version.rb
CHANGED
data/qas_dock_gem.gemspec
CHANGED
@@ -1,26 +1,26 @@
|
|
1
1
|
# frozen_string_literal: true
|
2
2
|
|
3
|
-
require_relative
|
3
|
+
require_relative 'lib/qas_dock_gem/version'
|
4
4
|
|
5
5
|
Gem::Specification.new do |spec|
|
6
|
-
spec.name
|
7
|
-
spec.version
|
8
|
-
spec.authors
|
9
|
-
spec.email
|
6
|
+
spec.name = 'qas_dock_gem'
|
7
|
+
spec.version = QasDockGem::VERSION
|
8
|
+
spec.authors = ['LucasKoritar23']
|
9
|
+
spec.email = ['lucas.gimenes23@gmail.com']
|
10
10
|
|
11
|
-
spec.summary
|
12
|
-
spec.description
|
13
|
-
spec.homepage
|
14
|
-
spec.license
|
11
|
+
spec.summary = 'A hello gem to the ruby world'
|
12
|
+
spec.description = 'I just created this gem to say hello for the ruby gems world, okay.'
|
13
|
+
spec.homepage = ''
|
14
|
+
spec.license = 'MIT'
|
15
15
|
|
16
|
-
spec.files
|
17
|
-
spec.executables
|
18
|
-
spec.test_files
|
19
|
-
spec.require_paths = [
|
16
|
+
spec.files = `git ls-files -z`.split("\x0")
|
17
|
+
spec.executables = spec.files.grep(%r{^bin/}) { |f| File.basename(f) }
|
18
|
+
spec.test_files = spec.files.grep(%r{^(test|spec|features)/})
|
19
|
+
spec.require_paths = ['lib']
|
20
20
|
|
21
|
-
spec.add_development_dependency
|
22
|
-
spec.add_development_dependency
|
23
|
-
spec.add_development_dependency
|
24
|
-
spec.add_development_dependency
|
25
|
-
spec.add_development_dependency
|
21
|
+
spec.add_development_dependency 'aws-sdk-secretsmanager'
|
22
|
+
spec.add_development_dependency 'bundler'
|
23
|
+
spec.add_development_dependency 'httparty'
|
24
|
+
spec.add_development_dependency 'logger'
|
25
|
+
spec.add_development_dependency 'redis'
|
26
26
|
end
|
metadata
CHANGED
@@ -1,17 +1,17 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: qas_dock_gem
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.1.
|
4
|
+
version: 0.1.30
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- LucasKoritar23
|
8
|
-
autorequire:
|
8
|
+
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
11
|
date: 2021-05-07 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
|
-
name:
|
14
|
+
name: aws-sdk-secretsmanager
|
15
15
|
requirement: !ruby/object:Gem::Requirement
|
16
16
|
requirements:
|
17
17
|
- - ">="
|
@@ -25,7 +25,7 @@ dependencies:
|
|
25
25
|
- !ruby/object:Gem::Version
|
26
26
|
version: '0'
|
27
27
|
- !ruby/object:Gem::Dependency
|
28
|
-
name:
|
28
|
+
name: bundler
|
29
29
|
requirement: !ruby/object:Gem::Requirement
|
30
30
|
requirements:
|
31
31
|
- - ">="
|
@@ -39,7 +39,7 @@ dependencies:
|
|
39
39
|
- !ruby/object:Gem::Version
|
40
40
|
version: '0'
|
41
41
|
- !ruby/object:Gem::Dependency
|
42
|
-
name:
|
42
|
+
name: httparty
|
43
43
|
requirement: !ruby/object:Gem::Requirement
|
44
44
|
requirements:
|
45
45
|
- - ">="
|
@@ -53,7 +53,7 @@ dependencies:
|
|
53
53
|
- !ruby/object:Gem::Version
|
54
54
|
version: '0'
|
55
55
|
- !ruby/object:Gem::Dependency
|
56
|
-
name:
|
56
|
+
name: logger
|
57
57
|
requirement: !ruby/object:Gem::Requirement
|
58
58
|
requirements:
|
59
59
|
- - ">="
|
@@ -108,7 +108,7 @@ homepage: ''
|
|
108
108
|
licenses:
|
109
109
|
- MIT
|
110
110
|
metadata: {}
|
111
|
-
post_install_message:
|
111
|
+
post_install_message:
|
112
112
|
rdoc_options: []
|
113
113
|
require_paths:
|
114
114
|
- lib
|
@@ -123,8 +123,8 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
123
123
|
- !ruby/object:Gem::Version
|
124
124
|
version: '0'
|
125
125
|
requirements: []
|
126
|
-
rubygems_version: 3.2
|
127
|
-
signing_key:
|
126
|
+
rubygems_version: 3.1.2
|
127
|
+
signing_key:
|
128
128
|
specification_version: 4
|
129
129
|
summary: A hello gem to the ruby world
|
130
130
|
test_files: []
|