使用RallyRestAPI,有没有办法查询ScopedAttributeDefinition类型?这似乎在Rally中定义自定义数据类型。我正在尝试构建我们在Rally中使用的自定义类型的数据字典,并将这些自定义类型与它们所属的对象相关联。 (如果没有意义,这里有一个例子:我们在Rally PortfolioItems上有一个名为Enabler Lead的自定义字段。我想查询Rally以获取PortfolioItem的所有自定义字段并获取启动器字段及其元数据,来自Rally REST API。)
我正在使用Java客户端。
答案 0 :(得分:0)
我提交了一个github问题,以添加对ScopedAttributeDefinition的支持:https://github.com/RallyTools/RallyRestToolkitForJava/issues/19
与此同时,您可以直接使用底层的http客户端解决它。此代码查询工作区中的所有项目,然后查找Portfolio Item的类型定义,然后为每个项目通过scopedattributedefinition端点获取所有自定义属性defs并打印出其隐藏/所需状态。
QueryRequest projectQuery = new QueryRequest("project");
projectQuery.setLimit(Integer.MAX_VALUE);
QueryResponse projectResponse = restApi.query(projectQuery);
QueryRequest typeDefQuery = new QueryRequest("typedefinition");
typeDefQuery.setQueryFilter(new QueryFilter("Name", "=", "Portfolio Item"));
QueryResponse typeDefResponse = restApi.query(typeDefQuery);
JsonObject piTypeDef = typeDefResponse.getResults().get(0).getAsJsonObject();
for(JsonElement projectResult : projectResponse.getResults()) {
JsonObject project = projectResult.getAsJsonObject();
System.out.println("Project: " + project.get("Name").getAsString());
//Begin hackery (note we're not handling multiple pages-
// if you have more than 200 custom attributes you'll have to page
String scopedAttributeDefUrl = "/project/" + project.get("ObjectID").getAsLong() +
"/typedefinition/" + piTypeDef.get("ObjectID").getAsLong() + "/scopedattributedefinition" +
"?fetch=Hidden,Required,Name&query=" + URLEncoder.encode("(Custom = true)", "utf-8");
String attributes = restApi.getClient().doGet(scopedAttributeDefUrl);
QueryResponse attributeResponse = new QueryResponse(attributes);
//End hackery
for(JsonElement customAttributeResult : attributeResponse.getResults()) {
JsonObject customAttribute = customAttributeResult.getAsJsonObject();
System.out.print("\tAttribute: " + customAttribute.get("Name").getAsString());
System.out.print(", Hidden: " + customAttribute.get("Hidden").getAsBoolean());
System.out.println(", Required: " + customAttribute.get("Required").getAsBoolean());
}
System.out.println();
}
只需从piTypeDef查询属性集合,就可以访问每个自定义字段的任何其他信息。