Class DefaultGoPluginApiResponse
java.lang.Object
com.thoughtworks.go.plugin.api.response.GoPluginApiResponse
com.thoughtworks.go.plugin.api.response.DefaultGoPluginApiResponse
Default implementation of GoPluginApiResponse
-
Field Summary
FieldsModifier and TypeFieldDescriptionstatic final intstatic final intstatic final intstatic final int -
Constructor Summary
ConstructorsConstructorDescriptionDefaultGoPluginApiResponse(int responseCode) Constructs DefaultGoPluginApiResponse with response codeDefaultGoPluginApiResponse(int responseCode, String responseBody) Constructs DefaultGoPluginApiResponseDefaultGoPluginApiResponse(int responseCode, String responseBody, Map<String, String> responseHeaders) Constructs DefaultGoPluginApiResponse -
Method Summary
Modifier and TypeMethodDescriptionvoidaddResponseHeader(String name, String value) Adds new response header.static DefaultGoPluginApiResponsebadRequest(String responseBody) Creates an instance DefaultGoPluginApiResponse which represents bad request with response code 400static DefaultGoPluginApiResponseCreates an instance DefaultGoPluginApiResponse which represents error request with response code 500static DefaultGoPluginApiResponseincompleteRequest(String responseBody) Creates an instance DefaultGoPluginApiResponse which represents incomplete request with response code 412Provides json formatted response bodyintProvides response code for the request sentProvides response headers as key value pair for the response.voidsetResponseBody(String responseBody) Sets response bodystatic DefaultGoPluginApiResponseCreates an instance DefaultGoPluginApiResponse which represents success request with response code 200
-
Field Details
-
SUCCESS_RESPONSE_CODE
public static final int SUCCESS_RESPONSE_CODE- See Also:
-
VALIDATION_FAILED
public static final int VALIDATION_FAILED- See Also:
-
BAD_REQUEST
public static final int BAD_REQUEST- See Also:
-
INTERNAL_ERROR
public static final int INTERNAL_ERROR- See Also:
-
-
Constructor Details
-
DefaultGoPluginApiResponse
public DefaultGoPluginApiResponse(int responseCode) Constructs DefaultGoPluginApiResponse with response code- Parameters:
responseCode- Response code for the response
-
DefaultGoPluginApiResponse
Constructs DefaultGoPluginApiResponse- Parameters:
responseCode- Response code for the responseresponseBody- Body of the response
-
DefaultGoPluginApiResponse
public DefaultGoPluginApiResponse(int responseCode, String responseBody, Map<String, String> responseHeaders) Constructs DefaultGoPluginApiResponse- Parameters:
responseCode- Response code for the responseresponseBody- Body of the responseresponseHeaders- The headers of the response
-
-
Method Details
-
incompleteRequest
Creates an instance DefaultGoPluginApiResponse which represents incomplete request with response code 412- Parameters:
responseBody- Response body- Returns:
- an instance of DefaultGoPluginApiResponse
-
badRequest
Creates an instance DefaultGoPluginApiResponse which represents bad request with response code 400- Parameters:
responseBody- Response body- Returns:
- an instance of DefaultGoPluginApiResponse
-
error
Creates an instance DefaultGoPluginApiResponse which represents error request with response code 500- Parameters:
responseBody- Response body- Returns:
- an instance of DefaultGoPluginApiResponse
-
success
Creates an instance DefaultGoPluginApiResponse which represents success request with response code 200- Parameters:
responseBody- Json formatted response body- Returns:
- an instance of DefaultGoPluginApiResponse
-
addResponseHeader
Adds new response header. Replace existing header with same name- Parameters:
name- Name of the headervalue- Value of the header
-
setResponseBody
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
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
Provides json formatted response body- Specified by:
responseBodyin classGoPluginApiResponse- Returns:
- response body
-