Package org.azd.utils

Class RestClient

java.lang.Object
org.azd.utils.RestClient

public abstract class RestClient extends Object
RestClient to call Azure DevOps REST API.
  • Constructor Details

    • RestClient

      public RestClient()
  • Method Details

    • send

      public static String send(RequestMethod requestMethod, Connection connection, String resourceId, String project, String area, String id, String resource, String apiVersion, Map queryString, Object requestBody, CustomHeader contentType) throws AzDException
      Request the Azure DevOps REST API and builds the request url dynamically based on resource id and endpoints passed
      Parameters:
      requestMethod - type of request GET, POST, PATCH, DELETE RequestMethod
      connection - name of the organization
      resourceId - pass the resource id.
      project - name of the project
      area - resource area
      id - resource id
      resource - resource area endpoint
      apiVersion - api version
      queryString - query string to append the url
      requestBody - Api payload for post, patch and put methods
      contentType - Type of content to request and accept as; Default is "Accept", "application/json"
      Returns:
      String response from Api
      Throws:
      AzDException - Default Api exception handler
    • send

      public static InputStream send(RequestMethod requestMethod, Connection connection, String resourceId, String project, String area, String id, String resource, String apiVersion, Map queryString, InputStream contentStream, CustomHeader contentType, boolean callback) throws AzDException
      Request the Azure DevOps REST API and builds the request url dynamically based on resource id and endpoints passed
      Parameters:
      requestMethod - type of request GET, POST, PATCH, DELETE RequestMethod
      connection - name of the organization
      resourceId - pass the resource id.
      project - name of the project
      area - resource area
      id - resource id
      resource - resource area endpoint
      apiVersion - api version
      queryString - query string to append the url
      contentStream - API payload as stream
      contentType - Type of content to request and accept as; Default is "Content-Type", "application/octet-stream"
      callback - If true default redirect policy will be applied. The redirect policy can be controlled in BaseRestClient class.
      Returns:
      InputStream from API
      Throws:
      AzDException - Default Api exception handler
    • send

      public static CompletableFuture<HttpResponse<InputStream>> send(String requestUrl, RequestMethod requestMethod, Connection connection, String resourceId, String project, String area, String id, String resource, String apiVersion, Map queryString, InputStream contentStream, CustomHeader contentType, boolean callback) throws AzDException
      Mediator for BaseRestClient and other Api implementations.
      Parameters:
      requestUrl - Pass the request url if any. Note that if the url is passed only this will be considered for Api call.
      requestMethod - type of request GET, POST, PATCH, DELETE RequestMethod
      connection - name of the organization
      resourceId - pass the resource id.
      project - name of the project
      area - resource area
      id - resource id
      resource - resource area endpoint
      apiVersion - api version
      queryString - query string to append the url
      contentStream - API payload as stream
      contentType - Type of content to request and accept as; Default is "Content-Type", "application/octet-stream"
      callback - If true default redirect policy will be applied. The redirect policy can be controlled
      Returns:
      A Future of Http response stream.
      Throws:
      AzDException - Default Api exception handler.
    • send

      public static String send(String requestUrl, RequestMethod requestMethod, Object requestBody, CustomHeader contentType, boolean callback) throws AzDException
      Mediator for BaseRestClient and other Api implementations.
      Parameters:
      requestUrl - Pass the request url if any. Note that if the url is passed only this will be considered for Api call.
      requestMethod - type of request GET, POST, PATCH, DELETE RequestMethod
      requestBody - API payload
      contentType - Type of content to request and accept as; Default is "Accept", "application/json"
      callback - If true default redirect policy will be applied. The redirect policy can be controlled
      Returns:
      String response from Api
      Throws:
      AzDException - Default Api exception handler
    • send

      public static String send(String requestUrl, Connection connection, RequestMethod requestMethod, Object requestBody, CustomHeader contentType, boolean callback) throws AzDException
      Mediator for BaseRestClient and other Api implementations.
      Parameters:
      requestUrl - Pass the request url if any. Note that if the url is passed only this will be considered for Api call.
      connection - Connection object to determine the mandatory details for calling the Api.
      requestMethod - type of request GET, POST, PATCH, DELETE RequestMethod
      requestBody - API payload
      contentType - Type of content to request and accept as; Default is "Accept", "application/json"
      callback - If true default redirect policy will be applied. The redirect policy can be controlled
      Returns:
      String response from Api
      Throws:
      AzDException - Default Api exception handler
    • send

      public static <T> CompletableFuture<HttpResponse<T>> send(String requestUrl, RequestMethod requestMethod, Connection connection, String resourceId, String project, String area, String id, String resource, String apiVersion, Map queryString, HttpRequest.BodyPublisher publisher, HttpResponse.BodyHandler<T> handler, Map<String,CustomHeader> headerMap, boolean callback) throws AzDException
      Helper method and a mediator for calling Azure DevOps REST Api.
      Type Parameters:
      T - Type name that is been returned.
      Parameters:
      requestUrl - Pass the request url if any. Note that if the url is passed only this will be considered for Api call.
      requestMethod - type of request GET, POST, PATCH, DELETE RequestMethod
      connection - name of the organization
      resourceId - pass the resource id.
      project - name of the project
      area - resource area
      id - resource id
      resource - resource area endpoint
      apiVersion - api version
      queryString - query string to append the url
      publisher - HttpRequest body publisher type
      handler - HttpResponse body type
      headerMap - Map of request headers.
      callback - If true default redirect policy will be applied
      Returns:
      Generic type can be String or Stream response from Api.
      Throws:
      AzDException - Default Api exception handler.