Class DefaultGoPluginApiResponse
- java.lang.Object
-
- com.thoughtworks.go.plugin.api.response.GoPluginApiResponse
-
- com.thoughtworks.go.plugin.api.response.DefaultGoPluginApiResponse
-
public class DefaultGoPluginApiResponse extends GoPluginApiResponse
Default implementation of GoPluginApiResponse
-
-
Field Summary
Fields Modifier and Type Field Description static intBAD_REQUESTstatic intINTERNAL_ERRORstatic intSUCCESS_RESPONSE_CODEstatic intVALIDATION_FAILED
-
Constructor Summary
Constructors Constructor Description DefaultGoPluginApiResponse(int responseCode)Constructs DefaultGoPluginApiResponse with response codeDefaultGoPluginApiResponse(int responseCode, java.lang.String responseBody)Constructs DefaultGoPluginApiResponseDefaultGoPluginApiResponse(int responseCode, java.lang.String responseBody, java.util.Map<java.lang.String,java.lang.String> responseHeaders)Constructs DefaultGoPluginApiResponse
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description voidaddResponseHeader(java.lang.String name, java.lang.String value)Adds new response header.static DefaultGoPluginApiResponsebadRequest(java.lang.String responseBody)Creates an instance DefaultGoPluginApiResponse which represents bad request with response code 400static DefaultGoPluginApiResponseerror(java.lang.String responseBody)Creates an instance DefaultGoPluginApiResponse which represents error request with response code 500static DefaultGoPluginApiResponseincompleteRequest(java.lang.String responseBody)Creates an instance DefaultGoPluginApiResponse which represents incomplete request with response code 412java.lang.StringresponseBody()Provides json formatted response bodyintresponseCode()Provides response code for the request sentjava.util.Map<java.lang.String,java.lang.String>responseHeaders()Provides response headers as key value pair for the response.voidsetResponseBody(java.lang.String responseBody)Sets response bodystatic DefaultGoPluginApiResponsesuccess(java.lang.String responseBody)Creates an instance DefaultGoPluginApiResponse which represents success request with response code 200
-
-
-
Field Detail
-
SUCCESS_RESPONSE_CODE
public static final int SUCCESS_RESPONSE_CODE
- See Also:
- Constant Field Values
-
VALIDATION_FAILED
public static final int VALIDATION_FAILED
- See Also:
- Constant Field Values
-
BAD_REQUEST
public static final int BAD_REQUEST
- See Also:
- Constant Field Values
-
INTERNAL_ERROR
public static final int INTERNAL_ERROR
- See Also:
- Constant Field Values
-
-
Constructor Detail
-
DefaultGoPluginApiResponse
public DefaultGoPluginApiResponse(int responseCode)
Constructs DefaultGoPluginApiResponse with response code- Parameters:
responseCode- Response code for the response
-
DefaultGoPluginApiResponse
public DefaultGoPluginApiResponse(int responseCode, java.lang.String responseBody)Constructs DefaultGoPluginApiResponse- Parameters:
responseCode- Response code for the responseresponseBody- Body of the response
-
DefaultGoPluginApiResponse
public DefaultGoPluginApiResponse(int responseCode, java.lang.String responseBody, java.util.Map<java.lang.String,java.lang.String> responseHeaders)Constructs DefaultGoPluginApiResponse- Parameters:
responseCode- Response code for the responseresponseBody- Body of the responseresponseHeaders- The headers of the response
-
-
Method Detail
-
incompleteRequest
public static DefaultGoPluginApiResponse incompleteRequest(java.lang.String responseBody)
Creates an instance DefaultGoPluginApiResponse which represents incomplete request with response code 412- Parameters:
responseBody- Response body- Returns:
- an instance of DefaultGoPluginApiResponse
-
badRequest
public static DefaultGoPluginApiResponse badRequest(java.lang.String responseBody)
Creates an instance DefaultGoPluginApiResponse which represents bad request with response code 400- Parameters:
responseBody- Response body- Returns:
- an instance of DefaultGoPluginApiResponse
-
error
public static DefaultGoPluginApiResponse error(java.lang.String responseBody)
Creates an instance DefaultGoPluginApiResponse which represents error request with response code 500- Parameters:
responseBody- Response body- Returns:
- an instance of DefaultGoPluginApiResponse
-
success
public static DefaultGoPluginApiResponse success(java.lang.String responseBody)
Creates an instance DefaultGoPluginApiResponse which represents success request with response code 200- Parameters:
responseBody- Json formatted response body- Returns:
- an instance of DefaultGoPluginApiResponse
-
addResponseHeader
public void addResponseHeader(java.lang.String name, java.lang.String value)Adds new response header. Replace existing header with same name- Parameters:
name- Name of the headervalue- Value of the header
-
setResponseBody
public void setResponseBody(java.lang.String responseBody)
Sets response body- Parameters:
responseBody- Json formatted response body represented as string
-
responseCode
public int responseCode()
Provides response code for the request sent- Specified by:
responseCodein classGoPluginApiResponse- Returns:
-
responseHeaders
public java.util.Map<java.lang.String,java.lang.String> responseHeaders()
Provides response headers as key value pair for the response. Response headers can be used to send any meta information related to response- Specified by:
responseHeadersin classGoPluginApiResponse- Returns:
- request headers as a Map
-
responseBody
public java.lang.String responseBody()
Provides json formatted response body- Specified by:
responseBodyin classGoPluginApiResponse- Returns:
- response body
-
-