Feature #325

Retrieve a list of all puppetclasses using the REST Api

Added by Gustavo Soares over 1 year ago. Updated over 1 year ago.

Status:Closed Start:06/16/2010
Priority:Normal Due date:
Assigned to:Ohad Levy % Done:

100%

Category:API
Target version:0.1-6
Backlog: Difficulity:
Votes: 0

Description

When playing aroung with the rest api I missed the feature to retrieve a list of all puppetclasses with their respective ids.

So, I alter the file app/controllers/puppetclasses_controller.rb to include a method to retrieve a json object with all classes with their ids.

def all
@puppetclasses = Puppetclass.find(:all, :select => "id, name", :order => 'id').to_json
render :json => @puppetclasses
end

Then, in the router.rb file I add:

map.connect "/puppetclasses/all", :controller => 'puppetclasses', :action => 'all'

I am not a big ruby expert, so I don't know if this is the best approach... :)

Associated revisions

Revision 3aa6ea3f48aa3c54e37970b9e6bbf5c96f6ca22d
Added by Ohad Levy over 1 year ago

fixes #325 - Retrieve a list of all puppet classes using the REST API

History

Updated by Ohad Levy over 1 year ago

patch? :)
look for the format_for for examples

Updated by Gustavo Soares over 1 year ago

Ohad Levy wrote:

patch? :) look for the format_for for examples

Take a look at this patch: http://github.com/gustavosoares/foreman/commit/daf07f29b9559f239c6de4ca877e6d7cdeb744b4

Updated by Ohad Levy over 1 year ago

  • Category set to API
  • Assigned to set to Ohad Levy
  • Target version set to 0.1-6

Updated by Ohad Levy over 1 year ago

  • Status changed from New to Ready For Testing
  • % Done changed from 0 to 100

Updated by Ohad Levy over 1 year ago

  • Status changed from Ready For Testing to Closed

Also available in: Atom PDF