class AwsSsmEnv::PathFetcher
Parameter Storeのパス階層を利用したFetcherクラスの実装サブクラス。 `path`と`recursive`を指定してパス階層のパラメータ値をまとめて取得する。 `ssm:GetParametersByPath`の認可が必要。
@author Ryohei Sonoda @since 0.1.0
Constants
- MAX_FETCH_SIZE
Public Class Methods
new(**args)
click to toggle source
@see AwsSsmEnv::Fetcher#initialize
@param [Hash] args AwsSsmEnv#load
の呼び出し時に渡された引数。 @option args [String] :path <required> 取得するパラメータのパス。 @option args [Boolean] :recursive <optional> サブパスのパラメータまで取得するかどうか。デフォルトはfalse(pathの階層のみ)。 @option args [Integer] :fetch_size <optional> 一度のAPI実行で取得するパラメータ数。最大10。デフォルトは10。
Calls superclass method
AwsSsmEnv::Fetcher::new
# File lib/aws-ssm-env/fetchers/path.rb, line 19 def initialize(**args) super @base_params = base_params(args) end
Protected Instance Methods
fetch(next_token)
click to toggle source
指定したパス階層配下のパラメータを取得する。 @see docs.aws.amazon.com/systems-manager/latest/APIReference/API_GetParametersByPath.html
# File lib/aws-ssm-env/fetchers/path.rb, line 30 def fetch(next_token) params = fetch_params(next_token) client.get_parameters_by_path(params) end
Private Instance Methods
base_params(path: nil, recursive: 'false', fetch_size: 10, **)
click to toggle source
# File lib/aws-ssm-env/fetchers/path.rb, line 37 def base_params(path: nil, recursive: 'false', fetch_size: 10, **) if path.nil? raise ArgumentError, 'path is required.' end { path: path, recursive: recursive?(recursive), with_decryption: with_decryption, max_results: detect_max_results(fetch_size) }.freeze end
detect_max_results(fetch_size)
click to toggle source
# File lib/aws-ssm-env/fetchers/path.rb, line 57 def detect_max_results(fetch_size) if fetch_size.nil? MAX_FETCH_SIZE elsif fetch_size.to_i > 10 MAX_FETCH_SIZE else fetch_size.to_i end end
fetch_params(next_token)
click to toggle source
# File lib/aws-ssm-env/fetchers/path.rb, line 67 def fetch_params(next_token) if next_token.nil? @base_params else @base_params.merge(next_token: next_token) end end
recursive?(recursive)
click to toggle source
# File lib/aws-ssm-env/fetchers/path.rb, line 49 def recursive?(recursive) if recursive.to_s.downcase == 'true' true else false end end