Package com.microsoft.graph.http
Class BaseRequest<T>
java.lang.Object
com.microsoft.graph.http.BaseRequest<T>
- Type Parameters:
T- the response class
- All Implemented Interfaces:
IHttpRequest
- Direct Known Subclasses:
BaseReferenceRequest,BaseWithReferenceRequest,BatchRequest,CustomRequest,PrimitiveRequest
An HTTP request.
-
Field Summary
FieldsModifier and TypeFieldDescriptionprotected List<FunctionOption>The function options for this requestprotected List<QueryOption>The query options for this requeststatic StringThe request stats header value format string -
Constructor Summary
ConstructorsConstructorDescriptionBaseRequest(String requestUrl, IBaseClient<?> client, List<? extends Option> options, Class<? extends T> responseClass)Creates the request -
Method Summary
Modifier and TypeMethodDescriptionprotected voidaddCountOption(boolean value)Adds the count query string value for the requestprotected voidaddExpandOption(String value)Sets the expand clause for the requestprotected voidaddFilterOption(String value)Sets the filter clause for the requestvoidaddFunctionOption(FunctionOption option)Adds a function optionvoidAdds a header to this requestprotected voidaddOrderByOption(String value)Sets the order by clause for the requestvoidaddQueryOption(QueryOption option)Adds a query optionprotected voidaddSelectOption(String value)Sets the select clause for the requestprotected voidaddSkipOption(int value)Sets the skip value for the requestprotected voidaddSkipTokenOption(String skipToken)Add Skip token for paginationprotected voidaddTopOption(int value)Sets the top value for the requestIBaseClient<?>Gets the clientlonggetDelay()Gets delay between retriesGets the function options for this requestGets the headersGets the HTTP method<requestBodyType, responseType, nativeRequestType>
nativeRequestTypegetHttpRequest(requestBodyType serializedObject)Returns the Request object to be executedintGets the max redirectsintGets max retriesGets the full list of options for this requestGets the query options for this requestGets the request URLGets the response typeGets the should redirect callbackGets the should retry callbackbooleanGets useCaches parameterprotected <T1> Tsend(HttpMethod method, T1 serializedObject)Sends this requestprotected <T1> CompletableFuture<T>sendAsync(HttpMethod method, T1 serializedObject)Sends this requestvoidsetDelay(long delay)Sets the delay in seconds between retiresvoidsetHttpMethod(HttpMethod httpMethod)Sets the HTTP methodvoidsetMaxRedirects(int maxRedirects)Sets the max redirectsvoidsetMaxRetries(int maxRetries)Sets the max retriesvoidsetShouldRedirect(IShouldRedirect shouldRedirect)Sets the should redirect callbackvoidsetShouldRetry(IShouldRetry shouldretry)Sets the should retry callbackvoidsetUseCaches(boolean useCaches)Sets useCaches parameter to cache the responsewithHttpMethod(HttpMethod httpMethod)Sets the HTTP method and returns the current requestMethods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, waitMethods inherited from interface com.microsoft.graph.http.IHttpRequest
getHttpRequest
-
Field Details
-
REQUEST_STATS_HEADER_VALUE_FORMAT_STRING
The request stats header value format string- See Also:
- Constant Field Values
-
queryOptions
The query options for this request -
functionOptions
The function options for this request
-
-
Constructor Details
-
BaseRequest
public BaseRequest(@Nonnull String requestUrl, @Nonnull IBaseClient<?> client, @Nullable List<? extends Option> options, @Nonnull Class<? extends T> responseClass)Creates the request- Parameters:
requestUrl- the URL to make the request againstclient- the client which can issue the requestoptions- the options for this requestresponseClass- the class for the response
-
-
Method Details
-
getRequestUrl
Gets the request URL- Specified by:
getRequestUrlin interfaceIHttpRequest- Returns:
- the request URL
-
getHttpRequest
@Nullable public <requestBodyType, responseType, nativeRequestType> nativeRequestType getHttpRequest(@Nullable requestBodyType serializedObject) throws ClientExceptionReturns the Request object to be executed- Specified by:
getHttpRequestin interfaceIHttpRequest- Type Parameters:
requestBodyType- the type of the serialized objectresponseType- the type of the responsenativeRequestType- type of a request for the native http client- Parameters:
serializedObject- the object to serialize at the body of the request- Returns:
- the Request object to be executed
- Throws:
ClientException
-
getHttpMethod
Gets the HTTP method- Specified by:
getHttpMethodin interfaceIHttpRequest- Returns:
- the HTTP method
-
getHeaders
Gets the headers- Specified by:
getHeadersin interfaceIHttpRequest- Returns:
- the headers
-
addHeader
Adds a header to this request- Specified by:
addHeaderin interfaceIHttpRequest- Parameters:
header- the name of the headervalue- the value of the header
-
setUseCaches
public void setUseCaches(boolean useCaches)Sets useCaches parameter to cache the response- Specified by:
setUseCachesin interfaceIHttpRequest- Parameters:
useCaches- the value of useCaches
-
getUseCaches
public boolean getUseCaches()Gets useCaches parameter- Specified by:
getUseCachesin interfaceIHttpRequest- Returns:
- the value of useCaches
-
sendAsync
@Nonnull protected <T1> CompletableFuture<T> sendAsync(@Nonnull HttpMethod method, @Nullable T1 serializedObject)Sends this request- Type Parameters:
T1- the type of the serialized body- Parameters:
method- the HTTP methodserializedObject- the object to serialize as the body- Returns:
- a future with the result
-
send
@Nullable protected <T1> T send(@Nullable HttpMethod method, @Nullable T1 serializedObject) throws ClientExceptionSends this request- Type Parameters:
T1- the type of the serialized body- Parameters:
method- the HTTP methodserializedObject- the object to serialize as the body- Returns:
- the response object
- Throws:
ClientException- an exception occurs if there was an error while the request was sent
-
getQueryOptions
Gets the query options for this request- Returns:
- the query options for this request
-
getFunctionOptions
Gets the function options for this request- Returns:
- the function options for this request
-
getOptions
Gets the full list of options for this request- Specified by:
getOptionsin interfaceIHttpRequest- Returns:
- the full list of options for this request
-
addQueryOption
Adds a query option- Parameters:
option- the query option to add
-
addFunctionOption
Adds a function option- Parameters:
option- the function option to add
-
addExpandOption
Sets the expand clause for the request- Parameters:
value- the expand clause
-
addFilterOption
Sets the filter clause for the request- Parameters:
value- the filter clause
-
addOrderByOption
Sets the order by clause for the request- Parameters:
value- the order by clause
-
addSelectOption
Sets the select clause for the request- Parameters:
value- the select clause
-
addTopOption
protected void addTopOption(int value)Sets the top value for the request- Parameters:
value- the max number of items to return
-
addSkipOption
protected void addSkipOption(int value)Sets the skip value for the request- Parameters:
value- of the number of items to skip
-
addSkipTokenOption
Add Skip token for pagination- Parameters:
skipToken- - Token for pagination
-
addCountOption
protected void addCountOption(boolean value)Adds the count query string value for the request- Parameters:
value- - Wheter to return the count or not
-
setHttpMethod
Sets the HTTP method- Parameters:
httpMethod- the HTTP method
-
withHttpMethod
Sets the HTTP method and returns the current request- Specified by:
withHttpMethodin interfaceIHttpRequest- Parameters:
httpMethod- the HTTP method- Returns:
- the current request
-
getClient
Gets the client- Returns:
- the client
-
getResponseType
Gets the response type- Returns:
- the response type
-
setMaxRedirects
public void setMaxRedirects(int maxRedirects)Sets the max redirects- Specified by:
setMaxRedirectsin interfaceIHttpRequest- Parameters:
maxRedirects- Max redirects that a request can take
-
getMaxRedirects
public int getMaxRedirects()Gets the max redirects- Specified by:
getMaxRedirectsin interfaceIHttpRequest- Returns:
- Max redirects that a request can take
-
setShouldRedirect
Sets the should redirect callback- Specified by:
setShouldRedirectin interfaceIHttpRequest- Parameters:
shouldRedirect- Callback called before doing a redirect
-
getShouldRedirect
Gets the should redirect callback- Specified by:
getShouldRedirectin interfaceIHttpRequest- Returns:
- Callback which is called before redirect
-
setShouldRetry
Sets the should retry callback- Specified by:
setShouldRetryin interfaceIHttpRequest- Parameters:
shouldretry- The callback called before retry
-
getShouldRetry
Gets the should retry callback- Specified by:
getShouldRetryin interfaceIHttpRequest- Returns:
- Callback called before retry
-
setMaxRetries
public void setMaxRetries(int maxRetries)Sets the max retries- Specified by:
setMaxRetriesin interfaceIHttpRequest- Parameters:
maxRetries- Max retries for a request
-
getMaxRetries
public int getMaxRetries()Gets max retries- Specified by:
getMaxRetriesin interfaceIHttpRequest- Returns:
- Max retries for a request
-
setDelay
public void setDelay(long delay)Sets the delay in seconds between retires- Specified by:
setDelayin interfaceIHttpRequest- Parameters:
delay- Delay in seconds between retries
-
getDelay
public long getDelay()Gets delay between retries- Specified by:
getDelayin interfaceIHttpRequest- Returns:
- Delay between retries in seconds
-