`
lauy
  • 浏览: 435548 次
  • 性别: Icon_minigender_1
  • 来自: 深圳
社区版块
存档分类
最新评论

rally api

阅读更多
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包装器

    必须通过获得Rally API的令牌。 需要访问Rally。 该包装器不支持基本身份验证。 安装 使用go get命令安装Rally: go get github.com/thomasbs/rally 用法 获取一个Rally对象: r := rally.New("rally_obtained_...

    rally-on-gcp

    按照以下说明获取Rally API密钥: : 安装和配置GCP客户端,包括服务帐户的JSON密钥文件 安装Terraform(当前为v0.12.28 ) 安装(如果尚未安装)Python 3.7或更高版本 每个目录都有一个readme.md其中包含更多说明...

    openstack 性能测试工具rally 使用说明

    openstack性能测试工具,rally的使用说明。可以测试opesntack各个组件的api性能,支持自定义场景,api调用plugin化,扩展方便。

    拉力加「Rally Plus」-crx插件

    +清除通知历史超过15天+查询优化0.1.46:修复了在GIF 0.1.47中捕获时超出的配额:已删除“”权限请求0.1.48:查询中不返回任何项目(出于娱乐目的)时的动画+允许在没有Rally API Key 0.1.49的情况​​下创建捕获...

    RallyTestExecutor:在CA Agile Central中导入测试用例的插件

    使用此项目后,如果您发现自己遇到了严重的问题,请不要与我联系, 话虽这么说,这个项目将做什么- 该项目将自动导出或导入excel中存在的测试,并在为其前端提供该Java Swing领域的Rally API密钥以及其他帮助程序...

    Python-Rally REST API-开源

    一个通过 REST 与 Rally 网络服务通信的 Python 库。 这是将我们在两个内部项目中所做的代码重构为一个泛型类的结果。 因此,API 仅实现我们在项目中需要的功能。

    rally-java-example:使用 Java 和 Gradle 的 Rally REST API 的示例用法

    Rally REST API for Java 示例这是一个使用 Java 和 Gradle 生成简单 Rally REST 示例的示例应用程序。 要查看所有运行的任务: ./gradlew tasks 要运行示例应用程序,请运行: ./gradlew run执照raise-java-example...

    lita-rally:Lita Bot的Rally插件

    config.handlers.rally.api_version -API版本。 默认值: “ v2.0” config.handlers.rally.read_only [true / false]禁用修改对象的命令。 默认值: false config.handlers.rally.action_state_map [哈希]到工件...

    rally:GitHub &lt;> Rally 集成

    GitHub 应用程序将在满足条件时使用成功/失败更新Checks API ,并提供在Rally 中发现的工件(即缺陷、用户故事)及其流程状态的详细报告。 开始 这个怎么运作 每次创建或更新拉取请求时, Rally + GitHub将检查title...

    RallyDev/Visual Studio.Net AddIn-开源

    使用Rally API Soap接口在Visual Studio 2005内部提供基本的Rally(http://www.rallydev.com)功能,作为VS.Net插件。 允许以故事为中心的视图或任务为中心的视图的故事和任务的单个用户视图。

    RallyRestToolkitForPython:适用于Rally的Python工具包

    pyral-用于Rally REST API的Python工具包通过使用软件包,您可以使用流行且高效的Python语言在Rally订阅中推送,拉取或数据。 pyral软件包在使用JSON的Rally REST Web服务API之上提供了一个平滑且易于使用的贴面。 ...

    rally-for-node:一个NPM软件包,带有简单易用的库,用于节点项目与Rally进行交互

    节点集会 节点集会利用集会库,因此具有... RALLY_USERNAME: 'yourID@yourcompany.com', //required if no api key, defaults to process.env.RALLY_USERNAME RALLY_PASSWORD: 'rally123'; //required if no api key,

    rally-salesforce-integration:随心所欲地将 Rally 数据同步到 Salesforce

    'apikey', // your api key 'My_Custom_Object__c', // sobject in your system 'My_ObjectID_Field__c', // the field you want to use for upsert new Map&lt;String&gt;{'Name' =&gt; 'Name'}, // field mappings, ...

    hystrix-network-auditor-agent-1.3.5.zip

    RallyRestToolkitForJava.zip,用于与Rally Rest API交互的Java工具包用于访问Rally的WebService API的Java工具包

    Rally-Recycle-Bin-Utilities

    回收站条目的 WSAPI URL 引用 结果输出到名为 recyclebin.csv 的 CSV 输出文件 raise_delete_recyclebin_items.rb 该脚本将输入一个 CSV 文件,该文件的字段格式与rally_recyclebin_report.rb 脚本输出的字段格式...

    IterationBurndownAndScopeTracking:使用Lookback API构造燃尽图的Custom Rally应用程序,显示理想,最大和实际燃尽指标以及冲刺范围

    此燃尽图利用Rally回溯API在迭代级别显示以下指标: 迭代范围(点或计数) 待办事项(小时) 理想燃尽(小时) 最大燃尽(小时) 指标 迭代范围 每天更新,其中跟踪迭代中的用户故事和缺陷的数量。 这有助于诊断...

    rally-tasks-for-echo

    回声的集会任务这是一个示例项目,显示了如何将使用AWS Lambda实现的Alexa Skill连接到S3文档和外部API。 该示例显示了使用从Rally获取缺陷列表。入门本示例使用在AWS Lambda上运行的Node.js代码构建。 如果您不熟悉...

    paginated-custom-grid:此应用程序为 Rally 的自定义网格应用程序添加了分页和更多结果

    这是使用 Rally 的 AppSDK 2.0RC3 和 Web 服务 API v. 2.0 修改后的 Rally 自定义网格应用程序。 请随意修改和修改以满足您自己的需求。 在 Rally 中使用时,请使用 deploy 文件夹中的 App-uncompressed.html 文件...

    App:Rally是一个基于活跃的社交媒体平台。 在今天的活动中结识新朋友!

    该应用程序利用Google Maps API来精确定位事件位置,并允许其他人在登录后加入事件。 Rally还允许用户在组页面上创建组,并允许具有配置文件的用户注册组。 创建组的人员还可以创建事件以发布到其组页面,从而允许...

Global site tag (gtag.js) - Google Analytics