Class: OpenStax::Aws::Secrets::ReadOnlyParameter

Inherits:
Object
  • Object
show all
Defined in:
lib/openstax/aws/secrets.rb

Instance Method Summary collapse

Constructor Details

#initialize(parameter, client) ⇒ ReadOnlyParameter

Helper object to hide the fact that tags and descriptions have to be accessed through separate API calls



227
228
229
230
# File 'lib/openstax/aws/secrets.rb', line 227

def initialize(parameter, client)
  @raw_parameter = parameter
  @client = client
end

Instance Method Details

#[](key) ⇒ Object



232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
# File 'lib/openstax/aws/secrets.rb', line 232

def [](key)
  case key
  when :type
    @raw_parameter.type
  when :value
    @raw_parameter.value
  when :tags
    raise "Not yet tested!"
    @tags ||= begin
      (@client.list_tags_for_resource({
        resource_type: "Parameter",
        resource_id: @raw_parameter.arn
      }).tag_list || []).map do |tag| {
        key: tag.key,
        value: tag.value
      } end
    end
  when :description
    @description ||= begin
      @client.describe_parameters({
        parameter_filters: [{
          key: "Name",
          option: "Equals",
          values: [@raw_parameter.name]
        }],
        max_results: 1
      }).parameters[0].description
    end
  end
end