Class FDRestUtils

java.lang.Object
flexagon.fd.model.integration.util.FDRestUtils

public class FDRestUtils extends Object
Utility functions for invoking REST calls, which can be used in custom Groovy code for change management and issue tracking system implementations
  • Constructor Details

    • FDRestUtils

      public FDRestUtils()
  • Method Details

    • testConnection

      public boolean testConnection(String pHostName, String pResourcePath, String pUserName, String pPassword) throws ApiException
      Test connection to external system with get call using basic authentication
      Parameters:
      pHostName - Base URL
      pResourcePath - Resource path to append to base URL
      pUserName - User name to connect as
      pPassword - Password to authenticate with
      Returns:
      Result of test connection
      Throws:
      ApiException - If response code is invalid
    • testConnection

      public boolean testConnection(String pHostName, String pResourcePath, String pBearerToken) throws ApiException
      Test connection to external system with get call using bearer token to authenticate
      Parameters:
      pHostName - Base URL
      pResourcePath - Resource path to append to base URL
      pBearerToken - Bearer token added to authentication header
      Returns:
      Result of test connection
      Throws:
      ApiException - If response code is invalid
    • getRequest

      public JsonObject getRequest(String pHostName, String pResourcePath, String pUserName, String pPassword) throws ApiException
      Invoke GET request using basic authentication
      Parameters:
      pHostName - Base URL
      pResourcePath - Resource path to append to base URL
      pUserName - User name to connect as
      pPassword - Password to authenticate with
      Returns:
      JSON response object
      Throws:
      ApiException - If response code is invalid
    • getRequest

      public JsonObject getRequest(String pHostName, String pResourcePath, Map<String,Serializable> pQueryParams, String pUserName, String pPassword) throws ApiException
      Invoke GET request using basic authentication
      Parameters:
      pHostName - Base URL
      pResourcePath - Resource path to append to base URL
      pQueryParams - Query parameter map
      pUserName - User name to connect as
      pPassword - Password to authenticate with
      Returns:
      JSON response object
      Throws:
      ApiException - If response code is invalid
    • getRequestArray

      public JsonArray getRequestArray(String pHostName, String pResourcePath, Map<String,Object> pQueryParams, String pUserName, String pPassword) throws ApiException
      Throws:
      ApiException
    • getRequestArray

      public JsonArray getRequestArray(String pHostName, String pResourcePath, Map<String,Object> pQueryParams, String pAccessToken) throws ApiException
      Throws:
      ApiException
    • getRequest

      public JsonObject getRequest(String pHostName, String pResourcePath, String pBearerToken) throws ApiException
      Invoke GET request using bearer token to authenticate
      Parameters:
      pHostName - Base URL
      pResourcePath - Resource path to append to base URL
      pBearerToken - Bearer token added to authentication header
      Returns:
      JSON response object
      Throws:
      ApiException - If response code is invalid
    • getRequest

      public JsonObject getRequest(String pHostName, String pResourcePath, Map<String,Serializable> pQueryParams, String pBearerToken) throws ApiException
      Invoke GET request using bearer token to authenticate
      Parameters:
      pHostName - Base URL
      pResourcePath - Resource path to append to base URL
      pQueryParams - Query parameter map
      pBearerToken - Bearer token added to authentication header
      Returns:
      JSON response object
      Throws:
      ApiException - If response code is invalid
    • getRequestArray

      public JsonArray getRequestArray(FlexRESTClient pClient) throws ApiException
      Throws:
      ApiException
    • postRequest

      public JsonObject postRequest(String pHostName, String pUserName, String pPassword, String pResourcePath, String pPayload) throws ApiException
      Invoke POST request using basic authentication
      Parameters:
      pHostName - Base URL
      pResourcePath - Resource path to append to base URL
      pUserName - User name to connect as
      pPassword - Password to authenticate with
      pPayload - JSON request body
      Returns:
      JSON response object
      Throws:
      ApiException - If response code is invalid
    • postRequest

      public JsonObject postRequest(String pHostName, String pUserName, String pPassword, String pResourcePath, Map<String,Serializable> pQueryParams, String pPayload) throws ApiException
      Invoke POST request using basic authentication
      Parameters:
      pHostName - Base URL
      pUserName - User name to connect as
      pPassword - Password to authenticate with
      pResourcePath - Resource path to append to base URL
      pQueryParams - Query parameter map
      pPayload - JSON request body
      Returns:
      JSON response object
      Throws:
      ApiException - If response code is invalid
    • postRequest

      public JsonObject postRequest(String pHostName, String pBearerToken, String pResourcePath, String pPayload) throws ApiException
      Invoke POST request using bearer token to authenticate
      Parameters:
      pHostName - Base URL
      pBearerToken - Bearer token added to authentication header
      pResourcePath - Resource path to append to base URL
      pPayload - JSON request body
      Returns:
      JSON response object
      Throws:
      ApiException - If response code is invalid
    • postRequest

      public JsonObject postRequest(String pHostName, String pBearerToken, String pResourcePath, Map<String,Serializable> pQueryParams, String pPayload) throws ApiException
      Invoke POST request using bearer token to authenticate
      Parameters:
      pHostName - Base URL
      pBearerToken - Bearer token added to authentication header
      pResourcePath - Resource path to append to base URL
      pQueryParams - Query parameter map
      pPayload - JSON request body
      Returns:
      JSON response object
      Throws:
      ApiException - If response code is invalid
    • putRequest

      public JsonObject putRequest(String pHostName, String pUserName, String pPassword, String pResourcePath, String pPayload) throws ApiException
      Invoke PUT request using basic authentication
      Parameters:
      pHostName - Base URL
      pUserName - User name to connect as
      pPassword - Password to authenticate with
      pResourcePath - Resource path to append to base URL
      pPayload - JSON request body
      Returns:
      JSON response object
      Throws:
      ApiException - If response code is invalid
    • putRequest

      public JsonObject putRequest(String pHostName, String pUserName, String pPassword, String pResourcePath, Map<String,Serializable> pQueryParams, String pPayload) throws ApiException
      Invoke PUT request using basic authentication
      Parameters:
      pHostName - Base URL
      pUserName - User name to connect as
      pPassword - Password to authenticate with
      pResourcePath - Resource path to append to base URL
      pQueryParams - Query parameter map
      pPayload - JSON request body
      Returns:
      JSON response object
      Throws:
      ApiException - If response code is invalid
    • putRequest

      public JsonObject putRequest(String pHostName, String pBearerToken, String pResourcePath, String pPayload) throws ApiException
      Invoke PUT request using bearer token to authenticate
      Parameters:
      pHostName - Base URL
      pBearerToken - Bearer token added to authentication header
      pResourcePath - Resource path to append to base URL
      pPayload - JSON request body
      Returns:
      JSON response object
      Throws:
      ApiException - If response code is invalid
    • putRequest

      public JsonObject putRequest(String pHostName, String pBearerToken, String pResourcePath, Map<String,Serializable> pQueryParams, String pPayload) throws ApiException
      Invoke PUT request using bearer token to authenticate
      Parameters:
      pHostName - Base URL
      pBearerToken - Bearer token added to authentication header
      pResourcePath - Resource path to append to base URL
      pQueryParams - Query parameter map
      pPayload - JSON request body
      Returns:
      JSON response object
      Throws:
      ApiException - If response code is invalid
    • patchRequest

      public JsonObject patchRequest(String pHostName, String pUserName, String pPassword, String pResourcePath, String pPayload) throws ApiException
      Invoke PATCH request using basic authentication
      Parameters:
      pHostName - Base URL
      pUserName - User name to connect as
      pPassword - Password to authenticate with
      pResourcePath - Resource path to append to base URL
      pPayload - JSON request body
      Returns:
      JSON response object
      Throws:
      ApiException - If response code is invalid
    • patchRequest

      public JsonObject patchRequest(String pHostName, String pUserName, String pPassword, String pResourcePath, Map<String,Serializable> pQueryParams, String pPayload) throws ApiException
      Invoke PATCH request using basic authentication
      Parameters:
      pHostName - Base URL
      pUserName - User name to connect as
      pPassword - Password to authenticate with
      pResourcePath - Resource path to append to base URL
      pQueryParams - Query parameter map
      pPayload - JSON request body
      Returns:
      JSON response object
      Throws:
      ApiException - If response code is invalid
    • patchRequest

      public JsonObject patchRequest(String pHostName, String pBearerToken, String pResourcePath, String pPayload) throws ApiException
      Invoke PATCH request using bearer token to authenticate
      Parameters:
      pHostName - Base URL
      pBearerToken - Bearer token added to authentication header
      pResourcePath - Resource path to append to base URL
      pPayload - JSON request body
      Returns:
      JSON response object
      Throws:
      ApiException - If response code is invalid
    • patchRequest

      public JsonObject patchRequest(String pHostName, String pBearerToken, String pResourcePath, Map<String,Serializable> pQueryParams, String pPayload) throws ApiException
      Invoke PATCH request using bearer token to authenticate
      Parameters:
      pHostName - Base URL
      pBearerToken - Bearer token added to authentication header
      pResourcePath - Resource path to append to base URL
      pQueryParams - Query parameter map
      pPayload - JSON request body
      Returns:
      JSON response object
      Throws:
      ApiException - If response code is invalid
    • checkValidJsonResponse

      public void checkValidJsonResponse(FlexRESTClientResponse pClientResponse) throws ApiException
      Throws:
      ApiException