Class: Runcible::Resources::ConsumerGroup

Inherits:
Base
  • Object
show all
Defined in:
lib/runcible/resources/consumer_group.rb

Overview

Direct Known Subclasses

Extensions::ConsumerGroup

Class Method Summary collapse

Methods inherited from Base

add_http_auth_header, add_oauth_header, call, combine_get_params, config, config=, generate_log_message, generate_payload, get_response, log_debug, log_exception, process_response, required_params

Class Method Details

.associate(id, criteria) ⇒ RestClient::Response

Associates Consumers with a Consumer Group

Parameters:

  • id (String)

    the ID of the consumer group

  • criteria (Hash)

    criteria based on Mongo syntax representing consumers to associate

Returns:

  • (RestClient::Response)


71
72
73
# File 'lib/runcible/resources/consumer_group.rb', line 71

def self.associate(id, criteria)
  call(:post, path(id) + "actions/associate/", :payload => {:required => criteria})
end

.create(id, optional = {}) ⇒ RestClient::Response

Creates a Consumer Group

Parameters:

  • id (String)

    the ID of the consumer

  • optional (Hash) (defaults to: {})

    container for all optional parameters

Returns:

  • (RestClient::Response)


45
46
47
48
# File 'lib/runcible/resources/consumer_group.rb', line 45

def self.create(id, optional={})
  required = required_params(binding.send(:local_variables), binding)
  call(:post, path, :payload => { :required => required, :optional => optional })
end

.delete(id) ⇒ RestClient::Response

Deletes a Consumer Group

Parameters:

  • id (String)

    the ID of the consumer group

Returns:

  • (RestClient::Response)


62
63
64
# File 'lib/runcible/resources/consumer_group.rb', line 62

def self.delete(id)
  call(:delete, path(id))
end

.install_units(id, units, options = {}) ⇒ RestClient::Response

Install a set of units to a Consumer Group

Parameters:

  • id (String)

    the ID of the consumer group

  • units (Array)

    array of units to install

  • options (Hash) (defaults to: {})

    hash of install options

Returns:

  • (RestClient::Response)


90
91
92
93
# File 'lib/runcible/resources/consumer_group.rb', line 90

def self.install_units(id, units, options={})
  required = required_params(binding.send(:local_variables), binding, ["id"])
  call(:post, path("#{id}/actions/content/install"), :payload => { :required => required })
end

.path(id = nil) ⇒ String

Generates the API path for Consumer Groups

Parameters:

  • id (String) (defaults to: nil)

    the ID of the consumer group

Returns:

  • (String)

    the consumer group path, may contain the id if passed



35
36
37
38
# File 'lib/runcible/resources/consumer_group.rb', line 35

def self.path(id=nil)
  groups = "consumer_groups/"
  id.nil? ? groups : groups + "#{id}/"
end

.retrieve(id) ⇒ RestClient::Response

Retrieves a Consumer Group

Parameters:

  • id (String)

    the ID of the consumer group

Returns:

  • (RestClient::Response)


54
55
56
# File 'lib/runcible/resources/consumer_group.rb', line 54

def self.retrieve(id)
  call(:get, path(id))
end

.unassociate(id, criteria) ⇒ RestClient::Response

Unassociates Consumers with a Consumer Group

Parameters:

  • id (String)

    the ID of the consumer group

  • criteria (Hash)

    criteria based on Mongo syntax representing consumers ta unassociate

Returns:

  • (RestClient::Response)


80
81
82
# File 'lib/runcible/resources/consumer_group.rb', line 80

def self.unassociate(id, criteria)
  call(:post, path(id) + "actions/unassociate/", :payload => {:required => criteria})
end

.uninstall_units(id, units, options = {}) ⇒ RestClient::Response

Uninstall a set of units from a Consumer Group

Parameters:

  • id (String)

    the ID of the consumer group

  • units (Array)

    array of units to uninstall

  • options (Hash) (defaults to: {})

    hash of uninstall options

Returns:

  • (RestClient::Response)


112
113
114
115
# File 'lib/runcible/resources/consumer_group.rb', line 112

def self.uninstall_units(id, units, options={})
  required = required_params(binding.send(:local_variables), binding, ["id"])
  call(:post, path("#{id}/actions/content/uninstall"), :payload => { :required => required })
end

.update_units(id, units, options = {}) ⇒ RestClient::Response

Update a set of units on a Consumer Group

Parameters:

  • id (String)

    the ID of the consumer group

  • units (Array)

    array of units to update

  • options (Hash) (defaults to: {})

    hash of update options

Returns:

  • (RestClient::Response)


101
102
103
104
# File 'lib/runcible/resources/consumer_group.rb', line 101

def self.update_units(id, units, options={})
  required = required_params(binding.send(:local_variables), binding, ["id"])
  call(:post, path("#{id}/actions/content/update"), :payload => { :required => required })
end