is there any way to make a rally ruby rest api call for workspaces return all of them instead of just default?

StackOverflow https://stackoverflow.com/questions/18049890

  •  23-06-2022
  •  | 
  •  

Question

i'd like to make a call to rally rest api via ruby toolkit to get all workspaces for a subscription, like so:

query = RallyAPI::RallyQuery.new()
query.type = "workspace"
query.fetch = "ObjectID,Name"
query.project_scope_up = false
query.project_scope_down = true
query.order = "Name Asc"
query.query_string = ""
errors = query.validate()
findResults = @connection.find query

but this call apparently only returns the default workspace.

i have semi-successfully been able to navigate to the list of all workspaces when navigating thru the Subscription object, but i would prefer to follow a standard method of going after entity types as illustrated above.

is anyone aware of a way to get all workspaces via a direct query against the workspace type?

Was it helpful?

Solution

WS API calls are workspace scoped. You are correct that the code above will always return only the default workspace, and that workspaces can be accessed via Subscription object. Here is an example:

require 'rally_api'

#Setup custom app information
headers = RallyAPI::CustomHttpHeader.new()
headers.name = "My Utility"
headers.vendor = "Nick M RallyLab"
headers.version = "1.0"

# Connection to Rally
config = {:base_url => "https://rally1.rallydev.com/slm"}
config[:username] = "user@domain.com"
config[:password] = "secret"
config[:workspace] = "W1"
config[:project] = "P1"
config[:headers] = headers #from RallyAPI::CustomHttpHeader.new()

rally = RallyAPI::RallyRestJson.new(config)


query = RallyAPI::RallyQuery.new()
query.type = :subscription
query.fetch = "Name,Workspaces,ObjectID"

results = rally.find(query)

sub = results.first
puts sub["Name"]
workspaces = sub["Workspaces"]

workspaces.each do |w|
    puts "Name: #{w["Name"]}, OID: #{w["ObjectID"]}"
end

Whenever a query is intended to look outside of a default workspace, a non-default workspace can be specified. Here is an example of a query on defects outside of the default workspace:

query = RallyAPI::RallyQuery.new()
query.type = :defect
query.fetch = "Name,FormattedID,CreationDate,Owner,UserName"
query.workspace = {"_ref" => "https://rally1.rallydev.com/slm/webservice/1.29/workspace/7777.js" } #optional
query.query_string = "(Owner.UserName = user@company.com)"

OTHER TIPS

I think adding

query.workspace = "null"

will remove the workspace scoping that is applied by default to queries. I haven't tried this with the Ruby client, but I think it should work.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top