1

我想通过 ruby​​ 工具包调用集合 rest api 以获取订阅的所有工作区,如下所示:

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

但这个调用显然只返回默认工作区。

在通过 Subscription 对象导航时,我已经成功地导航到所有工作区的列表,但我更愿意遵循如上图所示的追踪实体类型的标准方法。

有人知道通过直接查询工作区类型来获取所有工作区的方法吗?

4

2 回答 2

0

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)"
于 2013-08-05T05:53:29.643 回答
0

我认为添加

query.workspace = "null"

将删除默认应用于查询的工作区范围。我没有用 Ruby 客户端尝试过这个,但我认为它应该可以工作。

于 2013-08-05T14:40:00.157 回答