Class: SmPs::Parameter
- Inherits:
-
Object
- Object
- SmPs::Parameter
- Defined in:
- lib/smps/parameter.rb
Overview
SmPs Parameter management
Instance Attribute Summary collapse
-
#decrypt ⇒ Object
Returns the value of attribute decrypt.
-
#description ⇒ Object
Returns the value of attribute description.
-
#key_id ⇒ Object
Returns the value of attribute key_id.
-
#name ⇒ Object
Returns the value of attribute name.
-
#type ⇒ Object
Returns the value of attribute type.
Instance Method Summary collapse
- #exists? ⇒ Boolean
-
#history ⇒ Object
Not implemented yet.
-
#initialize(options) ⇒ Parameter
constructor
A new instance of Parameter.
-
#parameter ⇒ Object
Gets a parameter from Aws SSM.
-
#tag ⇒ Object
Not implemented yet.
-
#to_s ⇒ Object
Prints the current value.
-
#value ⇒ Object
Returns the value (String) or array if the ‘type` is StringList.
-
#value=(value) ⇒ Object
Set the value and mark the parameter as changed.
-
#write!(value = nil) ⇒ Object
Updates the parameter in the parameter store (remote).
Constructor Details
#initialize(options) ⇒ Parameter
Returns a new instance of Parameter.
8 9 10 11 12 13 14 15 16 17 |
# File 'lib/smps/parameter.rb', line 8 def initialize() @ssm = [:ssm] @name = [:name] @value = [:value] @type = [:type] @key_id = [:key_id] @decrypt = [:decrypt] || true fetch = [:fetch] || true parameter if fetch end |
Instance Attribute Details
#decrypt ⇒ Object
Returns the value of attribute decrypt.
6 7 8 |
# File 'lib/smps/parameter.rb', line 6 def decrypt @decrypt end |
#description ⇒ Object
Returns the value of attribute description.
6 7 8 |
# File 'lib/smps/parameter.rb', line 6 def description @description end |
#key_id ⇒ Object
Returns the value of attribute key_id.
6 7 8 |
# File 'lib/smps/parameter.rb', line 6 def key_id @key_id end |
#name ⇒ Object
Returns the value of attribute name.
6 7 8 |
# File 'lib/smps/parameter.rb', line 6 def name @name end |
#type ⇒ Object
Returns the value of attribute type.
6 7 8 |
# File 'lib/smps/parameter.rb', line 6 def type @type end |
Instance Method Details
#exists? ⇒ Boolean
48 49 50 |
# File 'lib/smps/parameter.rb', line 48 def exists? @exists end |
#history ⇒ Object
Not implemented yet.
65 66 67 |
# File 'lib/smps/parameter.rb', line 65 def history # get_parameter_history end |
#parameter ⇒ Object
Gets a parameter from Aws SSM.
20 21 22 23 24 25 26 27 28 29 |
# File 'lib/smps/parameter.rb', line 20 def parameter resp = @ssm.get_parameter( name: @name, with_decryption: @decrypt ) @type = resp.parameter.type @value = resp.parameter.value @exists = true rescue Aws::SSM::Errors::ParameterNotFound @exists = false end |
#tag ⇒ Object
Not implemented yet.
70 71 72 73 |
# File 'lib/smps/parameter.rb', line 70 def tag # add_tags_to_resource # remove_tags_from_resource end |
#to_s ⇒ Object
Prints the current value.
32 33 34 |
# File 'lib/smps/parameter.rb', line 32 def to_s @value end |
#value ⇒ Object
Returns the value (String) or array if the ‘type` is StringList
37 38 39 40 |
# File 'lib/smps/parameter.rb', line 37 def value return @value.split(',') if @type == 'StringList' @value end |
#value=(value) ⇒ Object
Set the value and mark the parameter as changed.
43 44 45 46 |
# File 'lib/smps/parameter.rb', line 43 def value=(value) @changed = true if value != @value @value = value end |
#write!(value = nil) ⇒ Object
Updates the parameter in the parameter store (remote).
53 54 55 56 57 58 59 60 61 62 |
# File 'lib/smps/parameter.rb', line 53 def write!(value = nil) @changed = true if value != @value @value = value if value @ssm.put_parameter( name: @name, value: @value, type: @type, description: @description, key_id: @key_id, overwrite: @exists, # allowed_pattern: "AllowedPattern", ) @value end |