class Eso::Configuration
This class represents the Configuration
that is sent to the server for new style Discovery Connections.
Attributes
Public Class Methods
Load a Configuration
object from a Hash
@param [Hash] hash The Hash containing the Configuration
object @return [Configuration] The Configuration
object which was in the Hash
# File lib/eso/configuration/configuration.rb, line 63 def self.load(hash) configuration = self.new(service_name: hash[:serviceName], config_name: hash[:configName], config_id: hash[:configID]) hash[:configurationAttributes][:properties].each do |prop| configuration.properties << ConfigurationAttribute.load(prop) end configuration end
# File lib/eso/configuration/configuration.rb, line 7 def initialize(service_name:, config_name:, properties:[], config_id:) @service_name = service_name @config_name = config_name @properties = properties @config_id = config_id end
Public Instance Methods
Delete a Configuration
attribute property value given the name of the property
@param [String] name The name of the property to update
# File lib/eso/configuration/configuration.rb, line 55 def delete_property(name) properties.delete_if{|attr| attr.property == name} end
Retrieve a Configuration
attribute property value given the name of the property
@param [String] name The name of the property to retrieve @return [String] The value of the property
# File lib/eso/configuration/configuration.rb, line 38 def property(name) prop = properties.find{|attr| attr.property == name} prop.value unless prop.nil? end
Convert the Configuration
to a Hash
@return [Hash] A Hash representation of the Configuration
# File lib/eso/configuration/configuration.rb, line 24 def to_hash hash = {:configId => @config_id, :serviceName => @service_name, :configName => @config_name, :configurationAttributes => {:valueClass => Eso::Values::OBJECT, :objectType => 'service_configuration', :properties => []}} properties.each {|prop| hash[:configurationAttributes][:properties] << prop.to_hash} end
Convert the Configuration
to a JSON string for sending to Nexpose
@return [String] A JSON String representation of the Configuration
# File lib/eso/configuration/configuration.rb, line 17 def to_json self.to_hash.to_json end
Update a Configuration
attribute property value given the name of the property
@param [String] name The name of the property to update @param [String] value The value of the property to update @return [String] The value of the property
# File lib/eso/configuration/configuration.rb, line 48 def update_property(name, value) properties.find{|attr| attr.property == name}.value = value end