qas_dock_gem 0.1.25 → 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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 9b37126b2553642c4c61db7566639fe73835b1e55dfce810f25e76077d14969a
4
- data.tar.gz: 794fc18a4b00c8b6fd11965f44a0a13866fa79b3c505cdef0f2e04c7cca378d7
3
+ metadata.gz: 0e5f0f121b13f8dc6d1106ea9cb4126ed4c182d795aa8d999c15bcb2df377fd0
4
+ data.tar.gz: 2c058ba1910dc842b97af337a8d3d59ed871d55d485f0e854d5b775ec8e96a80
5
5
  SHA512:
6
- metadata.gz: 209fb989ba7b983c41edae987a8b79f02bdc8a76e78cc5a657dae9d050d36cb9802608812b7dc0f62dce2da2fb028cee7cc7c0bc2c004c1909f2f277e81722cd
7
- data.tar.gz: eadb6b92f0bd1634bd162dc0b180587ff035fb1419744939548ab8d08a9d6c5e60a43dab8df5df0f9b5ca079a1309aacc54063eeaf80e4757d57a10ab5f63eb4
6
+ metadata.gz: d05f85e1d2e38f66056a0ea9dde29423214112e2e13d8408de310d91d2ae84785f714eaacb9d9aa0e0c041887c9a81c36e0a313dbbc462a930726f3c40370ee3
7
+ data.tar.gz: 3ee52b6c7a0ed6d5ddba204e9b62acff83506ffae77c7975ddc4191ec75dfda556b356c8b16661241a80bf07486dba7a8b4a947feac9dbaf34487e23b5e92e25
data/.gitignore CHANGED
@@ -6,3 +6,4 @@
6
6
  /pkg/
7
7
  /spec/reports/
8
8
  /tmp/
9
+ /.idea/
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 everyone, regardless of age, body size, visible or invisible disability, ethnicity, sex characteristics, gender identity and expression, level of experience, education, socio-economic status, nationality, personal appearance, race, religion, or sexual identity and orientation.
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
- address, without their explicit permission
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 appropriate and fair corrective action in response to any behavior that they deem inappropriate, threatening, offensive, or harmful.
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, issues, and other contributions that are not aligned to this Code of Conduct, and will communicate reasons for moderation decisions when appropriate.
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 the community in public spaces. Examples of representing our community include using an official e-mail address, posting via an official social media account, or acting as an appointed representative at an online or offline event.
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 for enforcement at lucas.gimenes23@gmail.com. All complaints will be reviewed and investigated promptly and fairly.
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 in violation of this Code of Conduct:
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 community.
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 and an explanation of why the behavior was inappropriate. A public apology may be requested.
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 unsolicited interaction with those enforcing the Code of Conduct, for a specified period of time. This includes avoiding interactions in community spaces as well as external channels like social media. Violating these terms may lead to a temporary or permanent ban.
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 period of time. No public or private interaction with the people involved, including unsolicited interaction with those enforcing the Code of Conduct, is allowed during this period. Violating these terms may lead to a permanent ban.
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 behavior, harassment of an individual, or aggression toward or disparagement of classes of individuals.
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
- available at https://www.contributor-covenant.org/version/2/0/code_of_conduct.html.
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 by [Mozilla's code of conduct enforcement ladder](https://github.com/mozilla/diversity).
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 at https://www.contributor-covenant.org/translations.
101
+ https://www.contributor-covenant.org/faq. Translations are available
102
+ at https://www.contributor-covenant.org/translations.
data/Gemfile CHANGED
@@ -1,8 +1,8 @@
1
1
  # frozen_string_literal: true
2
2
 
3
- source "https://rubygems.org"
3
+ source 'https://rubygems.org'
4
4
 
5
5
  # Specify your gem's dependencies in qas_dock_gem.gemspec
6
6
  gemspec
7
7
 
8
- gem "rake", "~> 13.0"
8
+ gem 'rake', '~> 13.0'
data/Gemfile.lock CHANGED
@@ -1,14 +1,14 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- qas_dock_gem (0.1.14)
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.452.0)
11
- aws-sdk-core (3.114.0)
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,15 +22,16 @@ GEM
22
22
  mime-types (~> 3.0)
23
23
  multi_xml (>= 0.5.2)
24
24
  jmespath (1.4.0)
25
- logger (1.4.3)
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)
29
29
  multi_xml (0.6.0)
30
30
  rake (13.0.3)
31
+ redis (4.2.5)
31
32
 
32
33
  PLATFORMS
33
- x86_64-linux-musl
34
+ x86_64-linux
34
35
 
35
36
  DEPENDENCIES
36
37
  aws-sdk-secretsmanager
@@ -39,6 +40,7 @@ DEPENDENCIES
39
40
  logger
40
41
  qas_dock_gem!
41
42
  rake (~> 13.0)
43
+ redis
42
44
 
43
45
  BUNDLED WITH
44
- 2.2.17
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 into a gem. Put your Ruby code in the file `lib/qas_dock_gem`. To experiment with that code, run `bin/console` for an interactive prompt.
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 prompt that will allow you to experiment.
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 version number in `version.rb`, and then run `bundle exec rake release`, which will create a git tag for the version, push git commits and the created tag, and push the `.gem` file to [rubygems.org](https://rubygems.org).
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 intended to be a safe, welcoming space for collaboration, and contributors are expected to adhere to the [code of conduct](https://github.com/[USERNAME]/qas_dock_gem/blob/master/CODE_OF_CONDUCT.md).
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 follow the [code of conduct](https://github.com/[USERNAME]/qas_dock_gem/blob/master/CODE_OF_CONDUCT.md).
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,118 +1,127 @@
1
1
  # frozen_string_literal: true
2
2
 
3
- require_relative "qas_dock_gem/version"
4
- require_relative "qas_dock_gem/services/aws_services"
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'
5
6
 
6
7
  module QasDockGem
7
8
  class RequestsAPI
8
- require "httparty"
9
- require "logger"
10
-
11
- def initialize
12
- @logger = Logger.new(STDOUT)
13
- end
14
-
15
- def initialize_headers(token, headers)
16
- headers_default = {"cache-control": "no-cache", "content-type": "application/json"}
17
-
18
- #seta o campo authorization caso o token seja diferente de nulo
19
- headers_default["Authorization"] = token unless token.nil?
20
-
21
- #define os headers parametrizados como um Hash caso seja nulo
22
- headers = {} if headers.nil?
9
+ require 'httparty'
23
10
 
24
- #realiza o merge dos headers defaults + os headers parametrizados
25
- headers_default.merge!(headers)
11
+ def initialize
12
+ require 'logger'
13
+ @logger = Logger.new($stdout)
14
+ end
26
15
 
27
- #remove o campo content-type caso não seja informado
28
- headers_default.delete(:"content-type") if headers_default[:"content-type"] == "" or headers_default[:"content-type"].nil?
29
-
30
- #retorna os headers
31
- JSON.parse(headers_default.to_json)
32
- end
33
-
34
- def initialize_request(params)
35
- formated_params = init_request_body(params[:token], params[:payload], params[:headers]) if params.include?(:payload)
36
- formated_params = init_request_query(params[:token], params[:query], params[:headers]) if params.include?(:query)
37
- 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' }
38
18
 
39
- #retorna os params formatados para a request
40
- formated_params
41
- end
19
+ # seta o campo authorization caso o token seja diferente de nulo
20
+ headers_default['Authorization'] = token unless token.nil?
42
21
 
43
- def init_request_body(token, payload, headers)
44
- final_headers = initialize_headers(token, headers)
45
- payload = {} if payload.nil?
46
- @logger.info("Payload: #{payload.to_json}")
47
- @logger.info("Headers: #{final_headers}")
22
+ # define os headers parametrizados como um Hash caso seja nulo
23
+ headers = {} if headers.nil?
48
24
 
49
- { :headers => final_headers, :body => payload.to_json }
50
- end
25
+ # realiza o merge dos headers defaults + os headers parametrizados
26
+ headers_default.merge!(headers)
51
27
 
52
- def init_request_basic_auth(token, basic_auth, headers)
53
- final_headers = initialize_headers(token, headers)
54
- payload = {} if payload.nil?
55
- @logger.info("Headers: #{final_headers}")
56
- { :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")
57
31
  end
58
32
 
59
- def init_request_query(token, query, headers)
60
- final_headers = initialize_headers(token, headers)
61
- query = {} if query.nil?
62
- @logger.info("Query: #{query}")
63
- @logger.info("Headers: #{final_headers}")
64
-
65
- { :headers => final_headers, :query => query }
66
- end
67
-
68
- def execute_post(params)
69
- formated_params = initialize_request(params)
70
- @logger.info("Realizando POST")
71
- @logger.info("URI: #{params[:uri]}")
72
- request = HTTParty.post(params[:uri], formated_params)
73
- @logger.info("URI Final: #{request.request.last_uri}")
74
- @logger.info("POST realizado \n")
75
- request
76
- end
33
+ # retorna os headers
34
+ JSON.parse(headers_default.to_json)
35
+ end
77
36
 
78
- def execute_get(params)
79
- formated_params = initialize_request(params)
80
- @logger.info("Realizando GET")
81
- @logger.info("URI: #{params[:uri]}")
82
- request = HTTParty.get(params[:uri], formated_params)
83
- @logger.info("URI Final: #{request.request.last_uri}")
84
- @logger.info("GET realizado \n")
85
- 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])
86
41
  end
87
42
 
88
- def execute_patch(params)
89
- formated_params = initialize_request(params)
90
- @logger.info("Realizando PATCH")
91
- @logger.info("URI: #{params[:uri]}")
92
- request = HTTParty.patch(params[:uri], formated_params)
93
- @logger.info("URI Final: #{request.request.last_uri}")
94
- @logger.info("PATCH realizado \n")
95
- request
96
- end
43
+ formated_params = init_request_query(params[:token], params[:query], params[:headers]) if params.include?(:query)
97
44
 
98
- def execute_put(params)
99
- formated_params = initialize_request(params)
100
- @logger.info("Realizando PUT")
101
- @logger.info("URI: #{params[:uri]}")
102
- request = HTTParty.put(params[:uri], formated_params)
103
- @logger.info("URI Final: #{request.request.last_uri}")
104
- @logger.info("PUT realizado \n")
105
- request
45
+ if params.include?(:basic_auth)
46
+ formated_params = init_request_basic_auth(params[:token], params[:basic_auth], params[:headers])
106
47
  end
107
48
 
108
- def execute_delete(params)
109
- formated_params = initialize_request(params)
110
- @logger.info("Realizando DELETE")
111
- @logger.info("URI: #{params[:uri]}")
112
- request = HTTParty.put(params[:uri], formated_params)
113
- @logger.info("URI Final: #{request.request.last_uri}")
114
- @logger.info("DELETE realizado \n")
115
- request
116
- end
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
117
126
  end
118
- end
127
+ end
@@ -1,23 +1,23 @@
1
+ # frozen_string_literal: true
2
+
1
3
  module QasDockGem
2
- module Aws
3
- class AwsServices
4
- def credentials_aws(access_key_id, secret_access_key_id, region)
5
- {
6
- access_key_id: access_key_id,
7
- secret_access_key: secret_access_key_id,
8
- region: region
9
- }
10
- end
11
-
12
- def init_secrets_manager(credentials)
13
- require "aws-sdk-secretsmanager"
14
- Aws::SecretsManager::Client.new(credentials)
15
- end
16
-
17
- def get_sm_secret_value(credentials, secret_name)
18
- secret = init_secrets_manager(credentials).get_secret_value(secret_id: "#{secret_name}")
19
- JSON.parse(secret.secret_string)
20
- end
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
+ }
22
11
  end
23
- 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
@@ -0,0 +1,47 @@
1
+ # frozen_string_literal: true
2
+
3
+ module QasDockGem
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}")
21
+ 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
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module QasDockGem
4
- VERSION = "0.1.25"
4
+ VERSION = '0.1.30'
5
5
  end
data/qas_dock_gem.gemspec CHANGED
@@ -1,25 +1,26 @@
1
1
  # frozen_string_literal: true
2
2
 
3
- require_relative "lib/qas_dock_gem/version"
3
+ require_relative 'lib/qas_dock_gem/version'
4
4
 
5
5
  Gem::Specification.new do |spec|
6
- spec.name = "qas_dock_gem"
7
- spec.version = QasDockGem::VERSION
8
- spec.authors = ["LucasKoritar23"]
9
- spec.email = ["lucas.gimenes23@gmail.com"]
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 = "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"
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 = `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"]
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 "bundler"
22
- spec.add_development_dependency "httparty"
23
- spec.add_development_dependency "logger"
24
- spec.add_development_dependency "aws-sdk-secretsmanager"
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'
25
26
  end
metadata CHANGED
@@ -1,15 +1,29 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: qas_dock_gem
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.25
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
- date: 2021-05-06 00:00:00.000000000 Z
11
+ date: 2021-05-07 00:00:00.000000000 Z
12
12
  dependencies:
13
+ - !ruby/object:Gem::Dependency
14
+ name: aws-sdk-secretsmanager
15
+ requirement: !ruby/object:Gem::Requirement
16
+ requirements:
17
+ - - ">="
18
+ - !ruby/object:Gem::Version
19
+ version: '0'
20
+ type: :development
21
+ prerelease: false
22
+ version_requirements: !ruby/object:Gem::Requirement
23
+ requirements:
24
+ - - ">="
25
+ - !ruby/object:Gem::Version
26
+ version: '0'
13
27
  - !ruby/object:Gem::Dependency
14
28
  name: bundler
15
29
  requirement: !ruby/object:Gem::Requirement
@@ -53,7 +67,7 @@ dependencies:
53
67
  - !ruby/object:Gem::Version
54
68
  version: '0'
55
69
  - !ruby/object:Gem::Dependency
56
- name: aws-sdk-secretsmanager
70
+ name: redis
57
71
  requirement: !ruby/object:Gem::Requirement
58
72
  requirements:
59
73
  - - ">="
@@ -87,13 +101,14 @@ files:
87
101
  - bin/setup
88
102
  - lib/qas_dock_gem.rb
89
103
  - lib/qas_dock_gem/services/aws_services.rb
104
+ - lib/qas_dock_gem/services/redis_services.rb
90
105
  - lib/qas_dock_gem/version.rb
91
106
  - qas_dock_gem.gemspec
92
107
  homepage: ''
93
108
  licenses:
94
109
  - MIT
95
110
  metadata: {}
96
- post_install_message:
111
+ post_install_message:
97
112
  rdoc_options: []
98
113
  require_paths:
99
114
  - lib
@@ -108,8 +123,8 @@ required_rubygems_version: !ruby/object:Gem::Requirement
108
123
  - !ruby/object:Gem::Version
109
124
  version: '0'
110
125
  requirements: []
111
- rubygems_version: 3.2.15
112
- signing_key:
126
+ rubygems_version: 3.1.2
127
+ signing_key:
113
128
  specification_version: 4
114
129
  summary: A hello gem to the ruby world
115
130
  test_files: []