CRUD Is Easy!

Given an instance of the RallyRestAPI:

rally = => <username>,
                         :password => <password>)


RallyRestAPI#create(<rally artifact type>, <artifact attributes as a hash>) returns a RestObject:

    defect = rally.create(:defect, :name => "Defect name")

#create will also accept a block, and yield the newly created reference to the block:

    rally.create(:defect, :name => "Defect name") do |defect|
      # do something with defect here

The block form is useful for creating relationships between objects in a readable way. For example, to create a User Story (represented by the type HierarchicalRequirement) with a task:

    rally.create(:hierarchical_requirement, :name => "User Story One", 
                                            :iteration => iteration_one) do |user_story|
      rally.create(:task, :name => "Task One", :work_product => user_story)

The above example will create a UserStory, pass it to the block, then create a Task on that User Story using the task’s ‘WorkProduct’ relationship.

Create an empty RestObject

As of 0.8.0, it is also possible to create an empty RestObject, set values, then call #save!.

For example:

    rally_rest =
    defect =
    defect.type = :defect
    defect.rally_rest = rally_rest = "Defect Name"!

Currently you must set the #type and #rally_rest, otherwise #save! will complain.


As mentioned above, RestObject will lazy read themselves on demand. If you need to force a RestObject to re-read itself, call RestObject#refresh.


There are two ways to update an object a RestObject can update itself:

    defect.update(:name => "new name")

Or the rest api can update it:

    rally.update(defect, :name => "new name")


There are two ways to delete an object; a RestObject can delete itself:


Or the rest api can delete it: