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 Details

  • Constructor Details

    • DefaultGoPluginApiResponse

      public DefaultGoPluginApiResponse(int responseCode)
      Constructs DefaultGoPluginApiResponse with response code
      Parameters:
      responseCode - Response code for the response
    • DefaultGoPluginApiResponse

      public DefaultGoPluginApiResponse(int responseCode, String responseBody)
      Constructs DefaultGoPluginApiResponse
      Parameters:
      responseCode - Response code for the response
      responseBody - Body of the response
    • DefaultGoPluginApiResponse

      public DefaultGoPluginApiResponse(int responseCode, String responseBody, Map<String,String> responseHeaders)
      Constructs DefaultGoPluginApiResponse
      Parameters:
      responseCode - Response code for the response
      responseBody - Body of the response
      responseHeaders - The headers of the response
  • Method Details

    • incompleteRequest

      public static DefaultGoPluginApiResponse incompleteRequest(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(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(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(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(String name, String value)
      Adds new response header. Replace existing header with same name
      Parameters:
      name - Name of the header
      value - Value of the header
    • setResponseBody

      public void setResponseBody(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:
      responseCode in class GoPluginApiResponse
      Returns:
    • responseHeaders

      public Map<String,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:
      responseHeaders in class GoPluginApiResponse
      Returns:
      request headers as a Map
    • responseBody

      public String responseBody()
      Provides json formatted response body
      Specified by:
      responseBody in class GoPluginApiResponse
      Returns:
      response body