Class: SsmEnv::Fetcher
- Inherits:
-
Object
- Object
- SsmEnv::Fetcher
- Defined in:
- lib/ssm_env/fetcher.rb
Instance Attribute Summary collapse
-
#client ⇒ Object
readonly
Returns the value of attribute client.
-
#ssm_params ⇒ Object
Returns the value of attribute ssm_params.
Instance Method Summary collapse
- #fetch(params:) ⇒ Object
-
#initialize(client:) ⇒ Fetcher
constructor
A new instance of Fetcher.
Constructor Details
#initialize(client:) ⇒ Fetcher
Returns a new instance of Fetcher.
8 9 10 |
# File 'lib/ssm_env/fetcher.rb', line 8 def initialize(client: ) @client = client end |
Instance Attribute Details
#client ⇒ Object (readonly)
Returns the value of attribute client.
6 7 8 |
# File 'lib/ssm_env/fetcher.rb', line 6 def client @client end |
#ssm_params ⇒ Object
Returns the value of attribute ssm_params.
5 6 7 |
# File 'lib/ssm_env/fetcher.rb', line 5 def ssm_params @ssm_params end |
Instance Method Details
#fetch(params:) ⇒ Object
12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 |
# File 'lib/ssm_env/fetcher.rb', line 12 def fetch(params: ) batch_size, self.ssm_params = 10, {} params.each_slice(batch_size) do |params_slice| response = self.client.get_parameters(names: params_slice, with_decryption: true) # Transforms to { :name => { value: value, type: type } } response_params = Hash[response.parameters.map { |item| [item.name.to_sym, {value: item.value, type: item.type}] }] response_params.each do |name, attributes| self.ssm_params[name] ||= {} self.ssm_params[name][:value] = attributes[:value] self.ssm_params[name][:type] = attributes[:type] end end self.ssm_params end |