Class: SmPs
- Inherits:
-
Object
- Object
- SmPs
- Defined in:
- lib/smps.rb,
lib/smps/version.rb,
lib/smps/parameter.rb
Overview
SmPs class queries and writes Paramstore parameters
Defined Under Namespace
Classes: Parameter
Constant Summary collapse
- VERSION =
'0.3.4'.freeze
Instance Method Summary collapse
-
#initialize(options = {}) ⇒ SmPs
constructor
A new instance of SmPs.
- #parameter(options) ⇒ Object
- #parameters_by_path(options) ⇒ Object
- #ssm_client ⇒ Object
- #store_parameters(params) ⇒ Object
Constructor Details
#initialize(options = {}) ⇒ SmPs
Returns a new instance of SmPs.
7 8 9 10 |
# File 'lib/smps.rb', line 7 def initialize( = {}) @credentials = [:credentials] @parameters = {} end |
Instance Method Details
#parameter(options) ⇒ Object
20 21 22 23 24 25 26 27 28 29 30 31 |
# File 'lib/smps.rb', line 20 def parameter() name = .fetch(:name) type = [:type] key_id = [: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
33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 |
# File 'lib/smps.rb', line 33 def parameters_by_path() path = .fetch(:path) recursive = [:recursive] decrypt = [:decrypt] || true @parameters_by_path_list = [] # while result has 'next_token' fetch_more = true next_token = nil while fetch_more params = ssm_client.get_parameters_by_path( path: path, recursive: recursive, with_decryption: decrypt, next_token: next_token ) if params.next_token next_token = params.next_token else fetch_more = false end store_parameters params end @parameters_by_path_list end |
#ssm_client ⇒ Object
12 13 14 15 16 17 18 |
# File 'lib/smps.rb', line 12 def ssm_client @ssm || @ssm = if @credentials.nil? Aws::SSM::Client.new else Aws::SSM::Client.new(credentials: @credentials) end end |
#store_parameters(params) ⇒ Object
58 59 60 61 62 63 64 65 66 67 |
# File 'lib/smps.rb', line 58 def store_parameters(params) return if params.nil? params.parameters.each do |parameter| @parameters[parameter.name] = SmPs::Parameter.new( ssm: ssm_client, fetch: false, name: parameter.name, value: parameter.value, type: parameter.type ) @parameters_by_path_list << @parameters[parameter.name] end end |