WS API 调用是工作区范围的。您是正确的,上面的代码将始终仅返回默认工作区,并且可以通过 Subscription 对象访问工作区。这是一个例子:
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
每当查询旨在查看默认工作区之外时,都可以指定非默认工作区。以下是对默认工作区之外的缺陷进行查询的示例:
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)"