Browse files

Added a readme. Also removed the StageState since the enum was not ad…

…ding any value
  • Loading branch information...
1 parent 65eb812 commit 08a31d6ed9776df081f22f5a574e4edcb552a996 @itspanzi committed with janmejay Nov 29, 2011
@@ -0,0 +1,35 @@
+h2. Introduction
+*Go API Client* is a client library that allows users to interact with a "Thoughtworks Studios Go": server's web API.
+The Go server exposes data and actions over HTTP RESTful APIs. This library lets users use Java as the client library.
+h2. Why?
+This library:
+* Shields the user from knowing the format of the XML documents returned as resources
+* Expose POJOs which give access to different domain concepts like pipeline, stage, job, material etc
+* Adds client side caching so that the Go server is not spammed more than required
+* Expose nice helper methods which help build custom reports quite easily
+* Provide version specific APIs
+h2. How do I use this?
+@TalkToGo@ is the interface that exposes everything that can be done with the Go server. There is a release specific implementation of this interface. For example, if you always want the latest server API, you can use the @TalkToGoLatest@ implementation.
+A sample usage of this client is as follows:
+HttpClientWrapper wrapper = new HttpClientWrapper("", 8153, "username", "password");
+TalkToGoLatest talkToGo = new TalkToGoLatest("pipeline", wrapper, false);
+Stage stage = talkToGo.latestStage("stage");
+System.out.println("The latest stage result is: " + stage.getResult());
+System.out.println(String.format("Latest stage info: %s %s %s", stage.getCounter(), stage.getPipelineLabel(), stage.getPipelineCounter()));
+You need to create a @HttpClientWrapper@ which is what is used to interact with the Go server. @TalkToGoLatest@ is created for the pipeline with name "pipeline". Using this instance, you can start interacting with the Go server to get the latest stage, latest pipeline instance etc.
+h2. API Documentation
+Since this is an API client, you can checkout the Javadocs on all the Java classes.
@@ -22,12 +22,12 @@
private final StagePipeline pipeline;
private final Date lastUpdated;
private final String result;
- private final StageState state;
+ private final String state;
private final String approvedBy;
private final List<StageJob> stageJobs;
private HttpClientWrapper httpClientWrapper;
- private Stage(String name, int counter, StagePipeline pipeline, Date lastUpdated, String result, StageState state, String approvedBy, List<StageJob> stageJobs) {
+ private Stage(String name, int counter, StagePipeline pipeline, Date lastUpdated, String result, String state, String approvedBy, List<StageJob> stageJobs) { = name;
this.counter = counter;
this.pipeline = pipeline;
@@ -46,7 +46,7 @@ public static Stage create(String resourceText) {
StagePipeline pip = new StagePipeline(attrVal(pipeline, "name"), attrVal(pipeline, "counter"), attrVal(pipeline, "label"), attrVal(pipeline, "href"));
Date lastUpdated = DateUtil.toDate(nodeText(doc, "//updated"));
String result = nodeText(doc, "//result");
- StageState state = StageState.valueOf(nodeText(doc, "//state"));
+ String state = nodeText(doc, "//state");
String approvedBy = nodeText(doc, "//approvedBy");
List<StageJob> stageJobs = stageJobs(doc);
return new Stage(name, Integer.parseInt(counter), pip, lastUpdated, result, state, approvedBy, stageJobs);
@@ -138,7 +138,7 @@ public String getResult() {
* @return the state of the stage.
- public StageState getState() {
+ public String getState() {
return state;
@@ -1,5 +0,0 @@
-package com.thoughtworks.go.domain;
-public enum StageState {
- Building, Failing, Passed, Failed, Unknown, Cancelled
@@ -9,15 +9,12 @@
-import java.util.Date;
import java.util.GregorianCalendar;
import java.util.List;
import java.util.TimeZone;
import static;
-import com.thoughtworks.go.domain.Pipeline;
-import com.thoughtworks.go.domain.Job;
-import com.thoughtworks.go.domain.Stage;
import com.thoughtworks.go.http.HttpClientWrapper;
public class StageTest {
@@ -35,7 +32,7 @@ public void shouldCreateAStage() throws Exception {
assertThat(stage.getLastUpdated(), is(gregorianCalendar.getTime()));
assertThat(stage.getResult(), is("Failed"));
- assertThat(stage.getState(), is(StageState.Failing));
+ assertThat(stage.getState(), is("Failing"));
assertThat(stage.getApprovedBy(), is("CruiseTimer"));
assertThat(stage.getStageLocator(), is("pipeline/9/stage/1"));

0 comments on commit 08a31d6

Please sign in to comment.