Class: Runcible::Resources::ConsumerGroup

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

Overview

Direct Known Subclasses

Extensions::ConsumerGroup

Instance Attribute Summary

Attributes inherited from Base

#logs

Instance Method Summary collapse

Methods inherited from Base

#add_http_auth_header, #add_oauth_header, #call, #combine_get_params, #config, #exception_to_log, #format_payload_json, #generate_payload, #get_response, #initialize, #lazy_config=, #log_debug, #log_exception, #log_info, #logger, #process_response, #required_params

Constructor Details

This class inherits a constructor from Runcible::Base

Instance 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)


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

def 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)


21
22
23
24
# File 'lib/runcible/resources/consumer_group.rb', line 21

def 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)


38
39
40
# File 'lib/runcible/resources/consumer_group.rb', line 38

def 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)


66
67
68
69
# File 'lib/runcible/resources/consumer_group.rb', line 66

def 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



11
12
13
14
# File 'lib/runcible/resources/consumer_group.rb', line 11

def 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)


30
31
32
# File 'lib/runcible/resources/consumer_group.rb', line 30

def 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)


56
57
58
# File 'lib/runcible/resources/consumer_group.rb', line 56

def 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)


88
89
90
91
# File 'lib/runcible/resources/consumer_group.rb', line 88

def 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)


77
78
79
80
# File 'lib/runcible/resources/consumer_group.rb', line 77

def 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