sorin
sorin

Reputation: 170508

How to get a story changelist using Rally python API?

How to get the list of changes made to a Story or Defect in Rally?

for r in rally.get('User Story', fetch=True, query=""): print r.Changesets

r.Changesets seems to always be an empty collection.

I also tried the rally.get('Revision'...) approach which seems to return me lots and lots of revisions but they do not contain any reference to the object (story/defect/...) being modified.

Also tried to use the query="ObjectID = %s" % r.FormattedID but this always returns nothing.

I also opened a bug on https://github.com/RallyTools/RallyRestToolkitForPython/issues/29 but I am not sure if this will get any attention soon enough.

Upvotes: 2

Views: 1296

Answers (1)

nickm
nickm

Reputation: 5966

Changeset object, which is a collection of Change objects in WS API is not related to revisions. Those objects are intended for integration with version control systems, e.g. Git, GitHub, Mercurial, Subversion connectors, etc, and have no meaning outside of integration context.

It is possible to traverse from an artifact, e.g. a user story to its revisions using the endpoints below. For example a user story query (FormattedID = US123) :

https://rally1.rallydev.com/slm/webservice/v2.0/hierarchicalrequirement?query=(FormattedID%20%3D%20US123)&fetch=true

will include a reference to RevisionHistory object, redacted for brevity

RevisionHistory: 
{
_ref: "https://rally1.rallydev.com/slm/webservice/v2.0/revisionhistory/19382984273", 
_type: "RevisionHistory"
},

This endpoint:

https://rally1.rallydev.com/slm/webservice/v2.0/revisionhistory/19382984273

returns Revision history object that has a referene to Revisions collection

{
RevisionHistory: 
{
_ref: "https://rally1.rallydev.com/slm/webservice/v2.0/revisionhistory/19382984273", 
_objectVersion: "3",
CreationDate: "2014-05-29T15:23:21.491Z",
ObjectID: 19382984273,
Revisions: 
{
_ref: "https://rally1.rallydev.com/slm/webservice/v2.0/RevisionHistory/19382984273/Revisions", 
_type: "Revision",
Count: 5
}
}
}

Here is an example of Revisions endpoint with narrowed fetch

https://rally1.rallydev.com/slm/webservice/v2.0/RevisionHistory/19382984273/Revisions?fetch=RevisionNumber,User,Description,CreationDate

Generally revision history queries are expensive and we do not recommend using them except in narrow scenarios.

v2.0 removed the ability to return child collections in the same response for performance reasons. Per WS API documentation fetching a collection will return an object with the count and the url from which to get the collection data. To get full objects a separate request is needed.

See this post that mentioned LookbackAPI. LBAPI allows to get historic data. There is no built-in support for LookbackAPI in pyral or any other Rally toolkits except AppSDK2 but LBAPI is language agnostic.

Upvotes: 2

Related Questions