lib/runcible/resources/consumer.rb in runcible-1.2.0 vs lib/runcible/resources/consumer.rb in runcible-1.3.0

- old
+ new

@@ -19,30 +19,28 @@ # NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE # LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION # OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION # WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. - module Runcible module Resources # @see https://pulp-dev-guide.readthedocs.org/en/latest/rest-api/consumer/index.html class Consumer < Runcible::Base - # 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 - def self.path(id=nil) - (id == nil) ? "consumers/" : "consumers/#{id}/" + def self.path(id = nil) + (id.nil?) ? 'consumers/' : "consumers/#{id}/" end # Creates a consumer # # @param [String] id the ID of the consumer # @param [Hash] optional container for all optional parameters # @return [RestClient::Response] - def create(id, optional={}) + def create(id, optional = {}) required = required_params(binding.send(:local_variables), binding) call(:post, path, :payload => { :required => required, :optional => optional }) end # Retrieves a consumer @@ -56,11 +54,11 @@ # Updates a consumer # # @param [String] id the ID of the consumer # @param [Hash] optional container for all optional parameters # @return [RestClient::Response] - def update(id, optional={}) + def update(id, optional = {}) call(:put, path(id), :payload => { :delta => optional }) end # Deletes a consumer # @@ -75,11 +73,11 @@ # @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] def upload_profile(id, content_type, profile) - required = required_params(binding.send(:local_variables), binding, ["id"]) + required = required_params(binding.send(:local_variables), binding, ['id']) call(:post, path("#{id}/profiles/"), :payload => { :required => required }) end # Retrieve a consumer profile # @@ -113,13 +111,13 @@ # @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] - 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 }) + 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 # Unbind a consumer to a repository for a given distributor # # @param [String] id the ID of the consumer @@ -134,51 +132,50 @@ # # @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] - def install_units(id, units, options={}) - required = required_params(binding.send(:local_variables), binding, ["id"]) + 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 # 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] - def update_units(id, units, options={}) - required = required_params(binding.send(:local_variables), binding, ["id"]) + 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 # 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] - def uninstall_units(id, units, options={}) - required = required_params(binding.send(:local_variables), binding, ["id"]) + 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 # (Re)Generate applicability for some set of consumers # # @param [Hash] options payload representing criteria # @return [RestClient::Response] def regenerate_applicability(options = {}) - call(:post, path("actions/content/regenerate_applicability/"), :payload => { :required => options}) + call(:post, path('actions/content/regenerate_applicability/'), :payload => { :required => options}) end # retrieve the applicability for some set of consumers # # @param [Hash] options hash representing criteria # @return [RestClient::Response] - def applicability(options={}) - call(:post, path + "content/applicability/", :payload => { :required => options }) + def applicability(options = {}) + call(:post, path + 'content/applicability/', :payload => { :required => options }) end - end end end