Java Toolkit for Rally REST API
Print this topicEmail this topicSave as PDF
The Java Toolkit for Rally REST API provides an intuitive Java API for accessing your Rally Data.
It provides a rich set of capabilities for querying, along with methods for creating, reading, updating, and deleting individual items.
Full API documentation
Web Services API documentation
Usage
Create a new Java 6 project in your favorite IDE and add rally-rest-api-1.0.jar to your classpath.
You will also need to add the following jars:
httpcore-4.1.4.jar
httpclient-4.1.3.jar
httpclient-cache-4.1.3.jar
commons-logging-1.1.1.jar
commons-codec-1.4.jar
gson-2.1.jar
All the jars except gson-2.1.jar can be found in httpcomponents-client-4.1.3-bin.zip in the archives for the Apache httpcomponents project.
The gson-2.1.jar file can be found in google-gson-2.1-release.zip on Google Code.
In your main method, instantiate a new RallyRestApi:
RallyRestApi restApi = new RallyRestApi(new URI("https://rally1.rallydev.com"), "user@company.com", "password");
The parameters for RallyRestApi are as follows:
Parameter Description Example
server* The Rally server to connect to. "https://rally1.rallydev.com"
userName* The username to connect to Rally with. "user@company.com"
password* The password to connect to Rally with. "password"
* = required parameter
Public Methods
RallyRestApi exposes the following public methods:
Method Name Parameters Description
create CreateRequest request* Create the object described by the request parameter. Returns a CreateResponse object containing the results of the request.
Example:
JsonObject newDefect = new JsonObject();
newDefect.addProperty("Name", "Test Defect");
CreateRequest createRequest = new CreateRequest("defect", newDefect);
CreateResponse createResponse = restApi.create(createRequest);
get GetRequest request* Retrieve the object described by the request parameter. Returns a GetResponse object containing the results of the request.
Example:
JsonObject updatedDefect = new JsonObject();
updatedDefect.addProperty("State", "Fixed");
UpdateRequest updateRequest = new UpdateRequest("/defect/1234.js", updatedDefect);
UpdateResponse updateResponse = restApi.update(updateRequest);
delete DeleteRequest request* Delete the object described by the request parameter. Returns a DeleteResponse object containing the results of the request.
Example:
DeleteRequest deleteRequest = new DeleteRequest("/defect/1234.js");
DeleteResponse deleteResponse = restApi.delete(deleteRequest);
query QueryRequest request* Query for objects matching the specified request. By default one page of data will be returned. Paging will automatically be performed if a limit is set on the request. Returns a QueryResponse object containing the results of the request.
Example:
QueryRequest defectRequest = new QueryRequest("defect");
defectRequest.setFetch(new Fetch("FormattedID", "Name", "State", "Priority"));
defectRequest.setQueryFilter(new QueryFilter("State", "=", "Fixed").and(new QueryFilter("Priority", "=", "Resolve Immediately")));
defectRequest.setOrder("Priority ASC,FormattedID ASC");
defectRequest.setPageSize(25);
defectRequest.setLimit(100);
QueryResponse queryResponse = restApi.query(defectRequest);
setWsapiVersion String wsapiVersion* Specifies the version of Rally's web services API to use. Defaults to 1.33
Example:
restApi.setWsapiVersion("1.29");
getWsapiVersion Gets the version of Rally's web services that the Toolkit is configured to use.
Example:
String version = restApi.getWsapiVersion();
setApplicationName String name* Set the name of your application. This name can be whatever you wish, and is added to the request headers of any web service requests your application makes. We encourage you to set this value, as it helps track usage of the toolkit.
Example:
restApi.setApplicationName("Universal Rally Data Extractor");
setApplicationVersion String version* Set the version of the application using the Java Toolkit. This version can be whatever you wish, and is added to the request headers of any web service requests your application makes.
Example:
restApi.setApplicationVersion("1.1");
setApplicationVendor String vendor* Set the vendor of the application using the Java Toolkit. This name can be whatever you wish (usually your company name), and is added to the request headers of any web service requests your application makes.
Example:
restApi.setApplicationVendor("My Company, Inc.");
setProxy java.net.URI proxy*
String userName
String password Set the proxy server to use, if you connect to Rally through a proxy server. By default, no proxy is configured. The userName and password parameters are optional, and are used if your proxy server requires authentication.
Example:
restApi.setProxy(new URI("http://myproxy.mycompany.com"), "MyProxyUsername", "MyProxyPassword");
close Closes open connections and releases resources. You should always call this method before your application exits.
Example:
restApi.close();
* = required parameter
Examples
The following code illustrates how to create, read, update, and delete a defect using the RallyRestApi object.
import com.google.gson.JsonObject;
import com.rallydev.rest.RallyRestApi;
import com.rallydev.rest.request.CreateRequest;
import com.rallydev.rest.request.DeleteRequest;
import com.rallydev.rest.request.GetRequest;
import com.rallydev.rest.request.UpdateRequest;
import com.rallydev.rest.response.CreateResponse;
import com.rallydev.rest.response.DeleteResponse;
import com.rallydev.rest.response.GetResponse;
import com.rallydev.rest.response.UpdateResponse;
import com.rallydev.rest.util.Ref;
import java.io.IOException;
import java.net.URI;
import java.net.URISyntaxException;
public class CrudExample {
public static void main(String[] args) throws URISyntaxException, IOException {
//Create and configure a new instance of RallyRestApi
RallyRestApi restApi = new RallyRestApi(new URI("https://rally1.rallydev.com"), "user@company.com", "password");
restApi.setApplicationName("CrudExample");
try {
//Create a defect
System.out.println("Creating defect...");
JsonObject newDefect = new JsonObject();
newDefect.addProperty("Name", "Test Defect");
CreateRequest createRequest = new CreateRequest("defect", newDefect);
CreateResponse createResponse = restApi.create(createRequest);
System.out.println(String.format("Created %s", createResponse.getObject().get("_ref").getAsString()));
//Read defect
String ref = Ref.getRelativeRef(createResponse.getObject().get("_ref").getAsString());
System.out.println(String.format("\nReading defect %s...", ref));
GetRequest getRequest = new GetRequest(ref);
GetResponse getResponse = restApi.get(getRequest);
JsonObject obj = getResponse.getObject();
System.out.println(String.format("Read defect. Name = %s, State = %s",
obj.get("Name").getAsString(), obj.get("State").getAsString()));
//Update defect
System.out.println("\nUpdating defect state...");
JsonObject updatedDefect = new JsonObject();
updatedDefect.addProperty("State", "Fixed");
UpdateRequest updateRequest = new UpdateRequest(ref, updatedDefect);
UpdateResponse updateResponse = restApi.update(updateRequest);
obj = updateResponse.getObject();
System.out.println(String.format("Updated defect. State = %s", obj.get("State").getAsString()));
//Delete defect
System.out.println("\nDeleting defect...");
DeleteRequest deleteRequest = new DeleteRequest(ref);
DeleteResponse deleteResponse = restApi.delete(deleteRequest);
if (deleteResponse.wasSuccessful()) {
System.out.println("Deleted defect.");
}
} finally {
//Release all resources
restApi.close();
}
}
}
The following code illustrates how to query for the top 5 highest priority defects:
import com.google.gson.JsonElement;
import com.google.gson.JsonObject;
import com.rallydev.rest.RallyRestApi;
import com.rallydev.rest.request.QueryRequest;
import com.rallydev.rest.response.QueryResponse;
import com.rallydev.rest.util.Fetch;
import com.rallydev.rest.util.QueryFilter;
import java.io.IOException;
import java.net.URI;
import java.net.URISyntaxException;
public class QueryExample {
public static void main(String[] args) throws URISyntaxException, IOException {
//Create and configure a new instance of RallyRestApi
RallyRestApi restApi = new RallyRestApi(new URI("https://rally1.rallydev.com"), "user@company.com", "password");
restApi.setApplicationName("QueryExample");
try {
System.out.println("Querying for top 5 highest priority unfixed defects...");
QueryRequest defects = new QueryRequest("defect");
defects.setFetch(new Fetch("FormattedID", "Name", "State", "Priority"));
defects.setQueryFilter(new QueryFilter("State", "<", "Fixed"));
defects.setOrder("Priority ASC,FormattedID ASC");
//Return up to 5, 1 per page
defects.setPageSize(1);
defects.setLimit(5);
QueryResponse queryResponse = restApi.query(defects);
if (queryResponse.wasSuccessful()) {
System.out.println(String.format("\nTotal results: %d", queryResponse.getTotalResultCount()));
System.out.println("Top 5:");
for (JsonElement result : queryResponse.getResults()) {
JsonObject defect = result.getAsJsonObject();
System.out.println(String.format("\t%s - %s: Priority=%s, State=%s",
defect.get("FormattedID").getAsString(),
defect.get("Name").getAsString(),
defect.get("Priority").getAsString(),
defect.get("State").getAsString()));
}
} else {
System.err.println("The following errors occurred: ");
for (String err : queryResponse.getErrors()) {
System.err.println("\t" + err);
}
}
} finally {
//Release resources
restApi.close();
}
}
}
Download Code:
rally-rest-api-1.0.zip
附件中是rally api的jar可以下载...
分享到:
相关推荐
必须通过获得Rally API的令牌。 需要访问Rally。 该包装器不支持基本身份验证。 安装 使用go get命令安装Rally: go get github.com/thomasbs/rally 用法 获取一个Rally对象: r := rally.New("rally_obtained_...
**Python-Rally REST API 开源库** Python-Rally REST API 是一个专为与Rally网络服务进行交互而设计的开源库。它允许开发者利用Python语言的便利性来访问和操作Rally中的数据,如需求、任务、迭代等。这个库源于两...
- **使用 Rally API**:通过调用 Rally 的 REST API,将转换后的数据发送到 Rally 平台,创建新的缺陷记录。 - **错误处理**:处理可能出现的导入错误,例如数据冲突、API 调用限制等。 在压缩包 `mantisbt2Rally-...
Rally插件可以是新的API调用方式,或是对Rally现有功能的扩展。 Rally作为一个性能测试工具,主要用于衡量和改进OpenStack服务的性能。它通过自动化的方式帮助开发人员和运维人员理解OpenStack在特定负载下的表现,...
按照以下说明获取Rally API密钥: : 安装和配置GCP客户端,包括服务帐户的JSON密钥文件 安装Terraform(当前为v0.12.28 ) 安装(如果尚未安装)Python 3.7或更高版本 每个目录都有一个readme.md其中包含更多说明...
Git2Rally的工作原理是通过Git的API获取提交信息,并利用Rally的REST API将这些信息更新到Rally的项目中。这涉及到对Git和Rally API的深入理解和使用。在Java中,我们可以使用HTTP客户端库,如Apache HttpClient或...
"SDK 文档"这部分指示开发者可以参考Rally Software的官方SDK文档来获取更详细的指导和API信息。Rally SDK通常提供了关于如何创建自定义视图、交互和报告的详细教程,包括如何使用Rally Grid和其他UI组件。 【压缩...
Rally SDK提供详尽的文档,指导开发者如何与Rally API进行交互,创建自定义视图和控件。这些文档涵盖了从安装SDK到创建复杂应用的各个步骤,包括设置环境、加载数据、渲染UI以及处理用户交互等。 ### 4. JavaScript...
3. **数据交互**:通过SDK中的`Rally.data.WsapiDataStore`,连接到Rally API,查询和加载工作区、发布和工作项等数据。 4. **界面构建**:使用HTML、CSS和JavaScript构建用户界面,并结合SDK提供的组件和方法,如`...
+清除通知历史超过15天+查询优化0.1.46:修复了在GIF 0.1.47中捕获时超出的配额:已删除“”权限请求0.1.48:查询中不返回任何项目(出于娱乐目的)时的动画+允许在没有Rally API Key 0.1.49的情况下创建捕获...
使用此项目后,如果您发现自己遇到了严重的问题,请不要与我联系, 话虽这么说,这个项目将做什么- 该项目将自动导出或导入excel中存在的测试,并在为其前端提供该Java Swing领域的Rally API密钥以及其他帮助程序...
这个库由一系列精心设计的类和函数组成,它们提供了便捷的方法来处理与Rally API交互时的复杂性,从而提高开发效率和代码可读性。 首先,我们需要理解Rally是什么。Rally是敏捷项目管理软件,它提供了一整套工具和...
通过深入研究这个代码库,我们可以学习到如何使用JavaScript和可能的第三方库(如React、Angular或Vue.js)来构建类似的应用,以及如何对接Rally API获取和处理数据。 在实际应用中,这样的平台可能会包括以下组件...
Rally REST API for Java 示例这是一个使用 Java 和 Gradle 生成简单 Rally REST 示例的示例应用程序。 要查看所有运行的任务: ./gradlew tasks 要运行示例应用程序,请运行: ./gradlew run执照raise-java-example...
config.handlers.rally.api_version -API版本。 默认值: “ v2.0” config.handlers.rally.read_only [true / false]禁用修改对象的命令。 默认值: false config.handlers.rally.action_state_map [哈希]到工件...
GitHub 应用程序将在满足条件时使用成功/失败更新Checks API ,并提供在Rally 中发现的工件(即缺陷、用户故事)及其流程状态的详细报告。 开始 这个怎么运作 每次创建或更新拉取请求时, Rally + GitHub将检查title...
使用Rally API Soap接口在Visual Studio 2005内部提供基本的Rally(http://www.rallydev.com)功能,作为VS.Net插件。 允许以故事为中心的视图或任务为中心的视图的故事和任务的单个用户视图。
pyral-用于Rally REST API的Python工具包通过使用软件包,您可以使用流行且高效的Python语言在Rally订阅中推送,拉取或数据。 pyral软件包在使用JSON的Rally REST Web服务API之上提供了一个平滑且易于使用的贴面。 ...
在Ruby编程语言的支持下,`rally-trello`能够访问Rally和Trello的API,进行数据的读取和写入。Ruby的强类型和面向对象特性使得代码结构清晰,易于维护。此外,Ruby社区有丰富的gem(库)资源,如`rally_api`和`...