Package com.microsoft.graph.http
Class CoreHttpProvider
java.lang.Object
com.microsoft.graph.http.CoreHttpProvider
- All Implemented Interfaces:
IHttpProvider<okhttp3.Request>
HTTP provider based off of OkHttp and msgraph-sdk-java-core library
-
Constructor Summary
ConstructorsConstructorDescriptionCoreHttpProvider(ISerializer serializer, ILogger logger, okhttp3.OkHttpClient httpClient) Creates the CoreHttpProvider -
Method Summary
Modifier and TypeMethodDescription<Result,Body>
okhttp3.RequestgetHttpRequest(IHttpRequest request, Class<Result> resultClass, Body serializable) Sends the HTTP requestGets the logger in useGets the serializer for this HTTP provider<Result,Body>
Resultsend(IHttpRequest request, Class<Result> resultClass, Body serializable) Sends the HTTP request<Result,Body, DeserializeType>
Resultsend(IHttpRequest request, Class<Result> resultClass, Body serializable, IStatefulResponseHandler<Result, DeserializeType> handler) Sends the HTTP request<Result,Body>
CompletableFuture<Result>sendAsync(IHttpRequest request, Class<Result> resultClass, Body serializable) Sends the HTTP request asynchronously<Result,BodyType, DeserializeType>
CompletableFuture<Result>sendAsync(IHttpRequest request, Class<Result> resultClass, BodyType serializable, IStatefulResponseHandler<Result, DeserializeType> handler) Sends the HTTP requeststatic StringstreamToString(InputStream input) Reads in a stream and converts it into a string
-
Constructor Details
-
CoreHttpProvider
public CoreHttpProvider(@Nonnull ISerializer serializer, @Nonnull ILogger logger, @Nonnull okhttp3.OkHttpClient httpClient) Creates the CoreHttpProvider- Parameters:
serializer- the serializerlogger- the logger for diagnostic informationhttpClient- the client to send http requests with
-
-
Method Details
-
getSerializer
Gets the serializer for this HTTP provider- Specified by:
getSerializerin interfaceIHttpProvider<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:
sendAsyncin interfaceIHttpProvider<okhttp3.Request>- Type Parameters:
Result- the type of the response objectBody- the type of the object to send to the service in the body of the request- Parameters:
request- the request descriptionserializable- the object to send to the service in the body of the requestresultClass- the class of the response from the service- Returns:
- a future with the result
-
sendAsync
@Nonnull public <Result,BodyType, CompletableFuture<Result> sendAsyncDeserializeType> (@Nonnull IHttpRequest request, @Nonnull Class<Result> resultClass, @Nullable BodyType serializable, @Nullable IStatefulResponseHandler<Result, DeserializeType> handler) throws ClientExceptionSends the HTTP request- Specified by:
sendAsyncin interfaceIHttpProvider<okhttp3.Request>- Type Parameters:
Result- the expected return type returnBodyType- the type of the object to send to the service in the body of the requestDeserializeType- the type of the HTTP response object- Parameters:
request- the request descriptionresultClass- the class of the response from the serviceserializable- the object to send to the service in the body of the requesthandler- 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:
sendin interfaceIHttpProvider<okhttp3.Request>- Type Parameters:
Result- the type of the response objectBody- the type of the object to send to the service in the body of the request- Parameters:
request- the request descriptionresultClass- the class of the response from the serviceserializable- 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, Result sendDeserializeType> (@Nonnull IHttpRequest request, @Nonnull Class<Result> resultClass, @Nullable Body serializable, @Nullable IStatefulResponseHandler<Result, DeserializeType> handler) throws ClientExceptionSends the HTTP request- Specified by:
sendin interfaceIHttpProvider<okhttp3.Request>- Type Parameters:
Result- the type of the response objectBody- the type of the object to send to the service in the body of the requestDeserializeType- the response handler for stateful response- Parameters:
request- the request descriptionresultClass- the class of the response from the serviceserializable- the object to send to the service in the body of the requesthandler- 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:
getHttpRequestin interfaceIHttpProvider<okhttp3.Request>- Type Parameters:
Result- the type of the response objectBody- the type of the object to send to the service in the body of the request- Parameters:
request- the request descriptionresultClass- the class of the response from the serviceserializable- 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
Reads in a stream and converts it into a string- Parameters:
input- the response body stream- Returns:
- the string result
-
getLogger
Gets the logger in use- Returns:
- the logger
-