Rally's Ruby REST API
Given an instance of the RallyRestAPI:
rally = RallyRestAPI.new(:username => <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 end
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) end
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.
As of 0.8.0, it is also possible to create an empty RestObject, set values, then call #save!.
rally_rest = RallyRestAPI.new(...) defect = RestObject.new defect.type = :defect defect.rally_rest = rally_rest defect.name = "Defect Name" defect.save!
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
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: