class Runcible::Resources::Consumer

@see docs.pulpproject.org/dev-guide/integration/rest-api/consumer/index.html

Public Class Methods

path(id = nil) click to toggle source

Generates the API path for Consumers

@param [String] id the ID of the consumer @return [String] the consumer path, may contain the id if passed

# File lib/runcible/resources/consumer.rb, line 9
def self.path(id = nil)
  id.nil? ? 'consumers/' : "consumers/#{id}/"
end

Public Instance Methods

applicability(options = {}) click to toggle source

retrieve the applicability for some set of consumers

@param [Hash] options hash representing criteria @return [RestClient::Response]

# File lib/runcible/resources/consumer.rb, line 170
def applicability(options = {})
  call(:post, path + 'content/applicability/', :payload => { :required => options })
end
bind(id, repo_id, distributor_id, optional = {}) click to toggle source

Bind a consumer to a repository for a given distributor

@param [String] id the ID of the consumer @param [String] repo_id the ID of the repository @param [String] distributor_id the ID of the distributor @param [Hash] optional optional parameters @return [RestClient::Response]

# File lib/runcible/resources/consumer.rb, line 100
def bind(id, repo_id, distributor_id, optional = {})
  required = required_params(binding.send(:local_variables), binding, ['id'])
  call(:post, path("#{id}/bindings/"), :payload => { :required => required, :optional => optional })
end
create(id, optional = {}) click to toggle source

Creates a consumer

@param [String] id the ID of the consumer @param [Hash] optional container for all optional parameters @return [RestClient::Response]

# File lib/runcible/resources/consumer.rb, line 18
def create(id, optional = {})
  required = required_params(binding.send(:local_variables), binding)
  call(:post, path, :payload => { :required => required, :optional => optional })
end
delete(id) click to toggle source

Deletes a consumer

@param [String] id the id of the consumer @return [RestClient::Response]

# File lib/runcible/resources/consumer.rb, line 51
def delete(id)
  call(:delete, path(id))
end
install_units(id, units, options = {}) click to toggle source

Install a set of units onto a consumer

@param [String] id the ID of the consumer @param [Array] units array of units to install @param [Hash] options hash of install options @return [RestClient::Response]

# File lib/runcible/resources/consumer.rb, line 121
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
regenerate_applicability(options = {}) click to toggle source

(Re)Generate applicability for some set of consumers

@param [Hash] options payload representing criteria @return [RestClient::Response]

# File lib/runcible/resources/consumer.rb, line 152
def regenerate_applicability(options = {})
  call(:post, path('actions/content/regenerate_applicability/'), :payload => { :required => options})
end
regenerate_applicability_by_id(id, options = {}) click to toggle source

(Re)Generate applicability for a single consumer. This does not cause a pulp lock, see pulp.plan.io/issues/1173#note-12

@param [String] id the ID of the consumer @param [Hash] options payload representing criteria @return [RestClient::Response]

# File lib/runcible/resources/consumer.rb, line 162
def regenerate_applicability_by_id(id, options = {})
  call(:post, path(id) + 'actions/content/regenerate_applicability/', :payload => { :required => options})
end
retrieve(id = nil) click to toggle source

Retrieves a consumer

@param [String] id the ID of the consumer @return [RestClient::Response]

# File lib/runcible/resources/consumer.rb, line 27
def retrieve(id = nil)
  call(:get, path(id))
end
retrieve_all() click to toggle source

Retrieves all consumers

@return [RestClient::Response]

# File lib/runcible/resources/consumer.rb, line 34
def retrieve_all
  retrieve
end
retrieve_binding(id, repo_id, distributor_id) click to toggle source

Retrieve a consumer binding

@param [String] id the ID of the consumer @param [String] repo_id the ID of the repository @param [String] distributor_id the ID of the distributor @return [RestClient::Response]

# File lib/runcible/resources/consumer.rb, line 81
def retrieve_binding(id, repo_id, distributor_id)
  call(:get, path("#{id}/bindings/#{repo_id}/#{distributor_id}"))
end
retrieve_bindings(id) click to toggle source

Retrieve all consumer bindings

@param [String] id the ID of the consumer @return [RestClient::Response]

# File lib/runcible/resources/consumer.rb, line 89
def retrieve_bindings(id)
  call(:get, path("#{id}/bindings/"))
end
retrieve_profile(id, content_type) click to toggle source

Retrieve a consumer profile

@param [String] id the ID of the consumer @param [String] content_type the content type @return [RestClient::Response]

# File lib/runcible/resources/consumer.rb, line 71
def retrieve_profile(id, content_type)
  call(:get, path("#{id}/profiles/#{content_type}/"))
end
unbind(id, repo_id, distributor_id) click to toggle source

Unbind a consumer to a repository for a given distributor

@param [String] id the ID of the consumer @param [String] repo_id the ID of the repository @param [String] distributor_id the ID of the distributor @return [RestClient::Response]

# File lib/runcible/resources/consumer.rb, line 111
def unbind(id, repo_id, distributor_id)
  call(:delete, path("#{id}/bindings/#{repo_id}/#{distributor_id}"))
end
uninstall_units(id, units, options = {}) click to toggle source

Uninstall a set of units from a consumer

@param [String] id the ID of the consumer @param [Array] units array of units to uninstall @param [Hash] options hash of uninstall options @return [RestClient::Response]

# File lib/runcible/resources/consumer.rb, line 143
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(id, optional = {}) click to toggle source

Updates a consumer

@param [String] id the ID of the consumer @param [Hash] optional container for all optional parameters @return [RestClient::Response]

# File lib/runcible/resources/consumer.rb, line 43
def update(id, optional = {})
  call(:put, path(id), :payload => { :delta => optional })
end
update_units(id, units, options = {}) click to toggle source

Update a set of units on a consumer

@param [String] id the ID of the consumer @param [Array] units array of units to update @param [Hash] options hash of update options @return [RestClient::Response]

# File lib/runcible/resources/consumer.rb, line 132
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
upload_profile(id, content_type, profile) click to toggle source

Create consumer profile

@param [String] id the ID of the consumer @param [String] content_type the content type @param [Hash] profile hash representing the consumer profile @return [RestClient::Response]

# File lib/runcible/resources/consumer.rb, line 61
def upload_profile(id, content_type, profile)
  required = required_params(binding.send(:local_variables), binding, ['id'])
  call(:post, path("#{id}/profiles/"), :payload => { :required => required })
end