Class: SmPs::Client

Inherits:
Object
  • Object
show all
Defined in:
lib/smps/client.rb

Overview

Presents a client interface with parameter parsing to aws ssm Allows querying and writing Paramstore parameters.

Instance Method Summary collapse

Constructor Details

#initialize(options = {}) ⇒ Client

Returns a new instance of Client.



11
12
13
14
# File 'lib/smps/client.rb', line 11

def initialize(options = {})
  @options = options
  @parameters = {}
end

Instance Method Details

#parameter(options) ⇒ Object

Creates a new SmPs::Parameter from the given options hash.



22
23
24
25
26
27
28
29
30
31
32
33
# File 'lib/smps/client.rb', line 22

def parameter(options)
  name = options.fetch(:name)
  type = options[:type]
  key_id = options[:key_id]
  unless @parameters.key?(name)
    @parameters[name] = SmPs::Parameter.new(
      ssm: ssm_client,
      name: name, type: type, key_id: key_id
    )
  end
  @parameters[name]
end

#parameters_by_path(options) ⇒ Object

Creates a list of all parameters filtered by path.



36
37
38
39
40
41
42
43
44
45
# File 'lib/smps/client.rb', line 36

def parameters_by_path(options)
  @parameters_by_path_list = []
  next_token = nil
  while (params = get_parameters_by_path_with_token(options, next_token))
    store_parameters params
    next_token = params.next_token
    break if next_token.nil? || next_token.empty?
  end
  parameters_result_hash options.fetch(:path), @parameters_by_path_list
end

#ssm_clientObject

Creates (if needed) and returns the ssm_client.



17
18
19
# File 'lib/smps/client.rb', line 17

def ssm_client
  @ssm_client ||= initialize_ssm_client
end