Class CoreHttpProvider

java.lang.Object
com.microsoft.graph.http.CoreHttpProvider
All Implemented Interfaces:
IHttpProvider<okhttp3.Request>

public class CoreHttpProvider extends Object implements IHttpProvider<okhttp3.Request>
HTTP provider based off of OkHttp and msgraph-sdk-java-core library
  • Constructor Details

    • CoreHttpProvider

      public CoreHttpProvider(@Nonnull ISerializer serializer, @Nonnull ILogger logger, @Nonnull okhttp3.OkHttpClient httpClient)
      Creates the CoreHttpProvider
      Parameters:
      serializer - the serializer
      logger - the logger for diagnostic information
      httpClient - the client to send http requests with
  • Method Details

    • getSerializer

      @Nullable public ISerializer getSerializer()
      Gets the serializer for this HTTP provider
      Specified by:
      getSerializer in interface IHttpProvider<okhttp3.Request>
      Returns:
      the serializer for this provider
    • sendAsync

      @Nonnull public <Result,​ Body> CompletableFuture<Result> sendAsync(@Nonnull IHttpRequest request, @Nonnull Class<Result> resultClass, @Nullable Body serializable)
      Sends the HTTP request asynchronously
      Specified by:
      sendAsync in interface IHttpProvider<okhttp3.Request>
      Type Parameters:
      Result - the type of the response object
      Body - the type of the object to send to the service in the body of the request
      Parameters:
      request - the request description
      serializable - the object to send to the service in the body of the request
      resultClass - the class of the response from the service
      Returns:
      a future with the result
    • sendAsync

      @Nonnull public <Result,​ BodyType,​ DeserializeType> CompletableFuture<Result> sendAsync(@Nonnull IHttpRequest request, @Nonnull Class<Result> resultClass, @Nullable BodyType serializable, @Nullable IStatefulResponseHandler<Result,​DeserializeType> handler) throws ClientException
      Sends the HTTP request
      Specified by:
      sendAsync in interface IHttpProvider<okhttp3.Request>
      Type Parameters:
      Result - the expected return type return
      BodyType - the type of the object to send to the service in the body of the request
      DeserializeType - the type of the HTTP response object
      Parameters:
      request - the request description
      resultClass - the class of the response from the service
      serializable - the object to send to the service in the body of the request
      handler - the handler for stateful response
      Returns:
      a future with the result
      Throws:
      ClientException - this exception occurs if the request was unable to complete for any reason
    • send

      @Nullable public <Result,​ Body> Result send(@Nonnull IHttpRequest request, @Nonnull Class<Result> resultClass, @Nullable Body serializable) throws ClientException
      Sends the HTTP request
      Specified by:
      send in interface IHttpProvider<okhttp3.Request>
      Type Parameters:
      Result - the type of the response object
      Body - the type of the object to send to the service in the body of the request
      Parameters:
      request - the request description
      resultClass - the class of the response from the service
      serializable - the object to send to the service in the body of the request
      Returns:
      the result from the request
      Throws:
      ClientException - an exception occurs if the request was unable to complete for any reason
    • send

      @Nullable public <Result,​ Body,​ DeserializeType> Result send(@Nonnull IHttpRequest request, @Nonnull Class<Result> resultClass, @Nullable Body serializable, @Nullable IStatefulResponseHandler<Result,​DeserializeType> handler) throws ClientException
      Sends the HTTP request
      Specified by:
      send in interface IHttpProvider<okhttp3.Request>
      Type Parameters:
      Result - the type of the response object
      Body - the type of the object to send to the service in the body of the request
      DeserializeType - the response handler for stateful response
      Parameters:
      request - the request description
      resultClass - the class of the response from the service
      serializable - the object to send to the service in the body of the request
      handler - the handler for stateful response
      Returns:
      the result from the request
      Throws:
      ClientException - this exception occurs if the request was unable to complete for any reason
    • getHttpRequest

      @Nullable public <Result,​ Body> okhttp3.Request getHttpRequest(@Nonnull IHttpRequest request, @Nonnull Class<Result> resultClass, @Nullable Body serializable) throws ClientException
      Sends the HTTP request
      Specified by:
      getHttpRequest in interface IHttpProvider<okhttp3.Request>
      Type Parameters:
      Result - the type of the response object
      Body - the type of the object to send to the service in the body of the request
      Parameters:
      request - the request description
      resultClass - the class of the response from the service
      serializable - the object to send to the service in the body of the request
      Returns:
      the result from the request
      Throws:
      ClientException - an exception occurs if the request was unable to complete for any reason
    • streamToString

      @Nullable public static String streamToString(@Nonnull InputStream input)
      Reads in a stream and converts it into a string
      Parameters:
      input - the response body stream
      Returns:
      the string result
    • getLogger

      @Nullable public ILogger getLogger()
      Gets the logger in use
      Returns:
      the logger