Skip to content
Dan Ryan edited this page Jun 13, 2012 · 5 revisions

Once you've configured Spice, you have access to low-level methods for the HTTP verbs, GET, POST, PUT, and DELETE, that can be used to send API requests to your Chef server. Note that accessing the Chef API in this manner will only return the JSON body, loaded as a Ruby hash, and will not be transformed into the various Spice model objects. For a full list of what's possible with the Chef API, please see the Opscode official documentation

Get a list of all clients:

Spice.get("/clients")

Get a specific node by the name "slappypants":

Spice.get("/nodes/slappypants")

Create a new role called "awesome":

Spice.post("/roles", :name => "awesome")

Make the client "sweet" an admin:

Spice.put("/clients/sweet", :admin => true)

Delete the node "foo.example.com":

Spice.delete("/nodes/foo.example.com")

Optional response types

Return a JSON string instead of a parsed:

Spice.get("/clients", {}, :json => true)

Return the raw Faraday::Response object

Spice.get("/clients", {}, :raw => true)
Clone this wiki locally