Class: RabbitMq::Plugin

Inherits:
Shared::Resource show all
Defined in:
lib/vas/rabbitmq/plugins.rb

Overview

A plugin in a RabbitMQ instance

Instance Attribute Summary collapse

Attributes inherited from Shared::Resource

#location, #security

Instance Method Summary collapse

Constructor Details

#initialize(location, client) ⇒ Plugin

Returns a new instance of Plugin.



49
50
51
52
53
54
55
56
57
58
59
# File 'lib/vas/rabbitmq/plugins.rb', line 49

def initialize(location, client)
  super(location, client)
  
  @name = details['name']
  @version = details['version']
  @instance = Instance.new(Util::LinkUtils.get_link_href(details, 'group-instance'), client)
  @state_location = Util::LinkUtils.get_link_href(details, 'state')
  
  plugin_image_location = Util::LinkUtils.get_link_href(details, 'plugin-image')
  @plugin_image = PluginImage.new(plugin_image_location, client) unless plugin_image_location.nil?
end

Instance Attribute Details

#instanceInstance (readonly)

Returns the instance that contains the plugin.

Returns:

  • (Instance)

    the instance that contains the plugin



43
44
45
# File 'lib/vas/rabbitmq/plugins.rb', line 43

def instance
  @instance
end

#nameString (readonly)

Returns the plugin’s name.

Returns:

  • (String)

    the plugin’s name



40
41
42
# File 'lib/vas/rabbitmq/plugins.rb', line 40

def name
  @name
end

#plugin_imagePluginImage (readonly)

Returns the plugin image, if any, that was used to create the plugin.

Returns:

  • (PluginImage)

    the plugin image, if any, that was used to create the plugin



46
47
48
# File 'lib/vas/rabbitmq/plugins.rb', line 46

def plugin_image
  @plugin_image
end

#versionString (readonly)

Returns the plugin’s version.

Returns:

  • (String)

    the plugin’s version



37
38
39
# File 'lib/vas/rabbitmq/plugins.rb', line 37

def version
  @version
end

Instance Method Details

#disablevoid

This method returns an undefined value.

Disables the plugin



76
77
78
# File 'lib/vas/rabbitmq/plugins.rb', line 76

def disable
  client.post(@state_location, { :status => 'DISABLED' })
end

#enablevoid

This method returns an undefined value.

Enables the plugin



69
70
71
# File 'lib/vas/rabbitmq/plugins.rb', line 69

def enable
  client.post(@state_location, { :status => 'ENABLED' })
end

#stateString

Returns the state of the plugin.

Returns:

  • (String)

    the state of the plugin



62
63
64
# File 'lib/vas/rabbitmq/plugins.rb', line 62

def state
  client.get(@state_location)['status']
end

#to_sString

Returns a string representation of the plugin.

Returns:

  • (String)

    a string representation of the plugin



81
82
83
# File 'lib/vas/rabbitmq/plugins.rb', line 81

def to_s
  "#<#{self.class} name='#@name' version='#@version'>"
end