runcible / lib / runcible / resources / consumer_group.rb @ 27b106f4
1 |
require 'active_support/core_ext/hash'
|
---|---|
2 |
|
3 |
module Runcible |
4 |
module Resources |
5 |
# @see https://docs.pulpproject.org/dev-guide/integration/rest-api/consumer/group/index.html
|
6 |
class ConsumerGroup < Runcible::Base |
7 |
# Generates the API path for Consumer Groups
|
8 |
#
|
9 |
# @param [String] id the ID of the consumer group
|
10 |
# @return [String] the consumer group path, may contain the id if passed
|
11 |
def path(id = nil) |
12 |
groups = 'consumer_groups/'
|
13 |
id.nil? ? groups : groups + "#{id}/"
|
14 |
end
|
15 |
|
16 |
# Creates a Consumer Group
|
17 |
#
|
18 |
# @param [String] id the ID of the consumer
|
19 |
# @param [Hash] optional container for all optional parameters
|
20 |
# @return [RestClient::Response]
|
21 |
def create(id, optional = {}) |
22 |
required = required_params(binding.send(:local_variables), binding)
|
23 |
call(:post, path, :payload => { :required => required, :optional => optional }) |
24 |
end
|
25 |
|
26 |
# Retrieves a Consumer Group
|
27 |
#
|
28 |
# @param [String] id the ID of the consumer group
|
29 |
# @return [RestClient::Response]
|
30 |
def retrieve(id) |
31 |
call(:get, path(id))
|
32 |
end
|
33 |
|
34 |
# Deletes a Consumer Group
|
35 |
#
|
36 |
# @param [String] id the ID of the consumer group
|
37 |
# @return [RestClient::Response]
|
38 |
def delete(id) |
39 |
call(:delete, path(id))
|
40 |
end
|
41 |
|
42 |
# Associates Consumers with a Consumer Group
|
43 |
#
|
44 |
# @param [String] id the ID of the consumer group
|
45 |
# @param [Hash] criteria criteria based on Mongo syntax representing consumers to associate
|
46 |
# @return [RestClient::Response]
|
47 |
def associate(id, criteria) |
48 |
call(:post, path(id) + 'actions/associate/', :payload => {:required => criteria}) |
49 |
end
|
50 |
|
51 |
# Unassociates Consumers with a Consumer Group
|
52 |
#
|
53 |
# @param [String] id the ID of the consumer group
|
54 |
# @param [Hash] criteria criteria based on Mongo syntax representing consumers ta unassociate
|
55 |
# @return [RestClient::Response]
|
56 |
def unassociate(id, criteria) |
57 |
call(:post, path(id) + 'actions/unassociate/', :payload => {:required => criteria}) |
58 |
end
|
59 |
|
60 |
# Install a set of units to a Consumer Group
|
61 |
#
|
62 |
# @param [String] id the ID of the consumer group
|
63 |
# @param [Array] units array of units to install
|
64 |
# @param [Hash] options hash of install options
|
65 |
# @return [RestClient::Response]
|
66 |
def install_units(id, units, options = {}) |
67 |
required = required_params(binding.send(:local_variables), binding, ['id']) |
68 |
call(:post, path("#{id}/actions/content/install"), :payload => { :required => required }) |
69 |
end
|
70 |
|
71 |
# Update a set of units on a Consumer Group
|
72 |
#
|
73 |
# @param [String] id the ID of the consumer group
|
74 |
# @param [Array] units array of units to update
|
75 |
# @param [Hash] options hash of update options
|
76 |
# @return [RestClient::Response]
|
77 |
def update_units(id, units, options = {}) |
78 |
required = required_params(binding.send(:local_variables), binding, ['id']) |
79 |
call(:post, path("#{id}/actions/content/update"), :payload => { :required => required }) |
80 |
end
|
81 |
|
82 |
# Uninstall a set of units from a Consumer Group
|
83 |
#
|
84 |
# @param [String] id the ID of the consumer group
|
85 |
# @param [Array] units array of units to uninstall
|
86 |
# @param [Hash] options hash of uninstall options
|
87 |
# @return [RestClient::Response]
|
88 |
def uninstall_units(id, units, options = {}) |
89 |
required = required_params(binding.send(:local_variables), binding, ['id']) |
90 |
call(:post, path("#{id}/actions/content/uninstall"), :payload => { :required => required }) |
91 |
end
|
92 |
end
|
93 |
end
|
94 |
end
|