Share via


BaseRequest<T> Class

  • java.lang.Object
    • com.microsoft.graph.http.BaseRequest<T>

Type Parameters

T

the response class

Implements

public abstract class BaseRequest<T>
implements IHttpRequest

An HTTP request.

Field Summary

Modifier and Type Field and Description
static final java.lang.String REQUEST_STATS_HEADER_VALUE_FORMAT_STRING

The request stats header value format string

protected final java.util.List<FunctionOption> functionOptions

The function options for this request

protected final java.util.List<QueryOption> queryOptions

The query options for this request

Constructor Summary

Constructor Description
BaseRequest(String requestUrl, IBaseClient<?> client, List<? extends Option> options, Class<? extends T> responseClass)

Creates the request

Method Summary

Modifier and Type Method and Description
protected T send(HttpMethod method, T1 serializedObject)

Sends this request

protected java.util.concurrent.CompletableFuture<T> sendAsync(HttpMethod method, T1 serializedObject)

Sends this request

nativeRequestType <requestBodyType,responseType,nativeRequestType>getHttpRequest(requestBodyType serializedObject)

Returns the Request object to be executed

protected void addCountOption(boolean value)

Adds the count query string value for the request

protected void addExpandOption(String value)

Sets the expand clause for the request

protected void addFilterOption(String value)

Sets the filter clause for the request

void addFunctionOption(FunctionOption option)

Adds a function option

void addHeader(String header, String value)

Adds a header to this request

protected void addOrderByOption(String value)

Sets the order by clause for the request

void addQueryOption(QueryOption option)

Adds a query option

protected void addSelectOption(String value)

Sets the select clause for the request

protected void addSkipOption(int value)

Sets the skip value for the request

protected void addSkipTokenOption(String skipToken)

Add Skip token for pagination

protected void addTopOption(int value)

Sets the top value for the request

IBaseClient<?> getClient()

Gets the client

long getDelay()

Gets delay between retries

java.util.List<FunctionOption> getFunctionOptions()

Gets the function options for this request

java.util.List<HeaderOption> getHeaders()

Gets the headers

HttpMethod getHttpMethod()

Gets the HTTP method

int getMaxRedirects()

Gets the max redirects

int getMaxRetries()

Gets max retries

java.util.List<Option> getOptions()

Gets the full list of options for this request

java.util.List<QueryOption> getQueryOptions()

Gets the query options for this request

java.net.URL getRequestUrl()

Gets the request URL

java.lang.Class<> getResponseType()

Gets the response type

IShouldRedirect getShouldRedirect()

Gets the should redirect callback

IShouldRetry getShouldRetry()

Gets the should retry callback

boolean getUseCaches()

Gets useCaches parameter

void setDelay(long delay)

Sets the delay in seconds between retires

void setHttpMethod(HttpMethod httpMethod)

Sets the HTTP method

void setMaxRedirects(int maxRedirects)

Sets the max redirects

void setMaxRetries(int maxRetries)

Sets the max retries

void setShouldRedirect(IShouldRedirect shouldRedirect)

Sets the should redirect callback

void setShouldRetry(IShouldRetry shouldretry)

Sets the should retry callback

void setUseCaches(boolean useCaches)

Sets useCaches parameter to cache the response

IHttpRequest withHttpMethod(HttpMethod httpMethod)

Sets the HTTP method and returns the current request

Methods inherited from java.lang.Object

java.lang.Object.clone java.lang.Object.equals java.lang.Object.finalize java.lang.Object.getClass java.lang.Object.hashCode java.lang.Object.notify java.lang.Object.notifyAll java.lang.Object.toString java.lang.Object.wait java.lang.Object.wait java.lang.Object.wait

Field Details

REQUEST_STATS_HEADER_VALUE_FORMAT_STRING

public static final String REQUEST_STATS_HEADER_VALUE_FORMAT_STRING

The request stats header value format string

functionOptions

protected final List functionOptions

The function options for this request

queryOptions

protected final List queryOptions

The query options for this request

Constructor Details

BaseRequest

public BaseRequest(String requestUrl, IBaseClient client, List options, Class responseClass)

Creates the request

Parameters:

requestUrl - the URL to make the request against
client - the client which can issue the request
options - the options for this request
responseClass - the class for the response

Method Details

send

protected T send(HttpMethod method, T1 serializedObject)

Sends this request

Parameters:

method - the HTTP method
serializedObject - 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

sendAsync

protected CompletableFuture sendAsync(HttpMethod method, T1 serializedObject)

Sends this request

Parameters:

method - the HTTP method
serializedObject - the object to serialize as the body

Returns:

a future with the result

<requestBodyType,responseType,nativeRequestType>getHttpRequest

public nativeRequestType getHttpRequest(requestBodyType serializedObject)

Returns the Request object to be executed

Parameters:

serializedObject - the object to serialize at the body of the request

Returns:

the Request object to be executed

Throws:

addCountOption

protected void addCountOption(boolean value)

Adds the count query string value for the request

Parameters:

value -
  • Wheter to return the count or not

addExpandOption

protected void addExpandOption(String value)

Sets the expand clause for the request

Parameters:

value - the expand clause

addFilterOption

protected void addFilterOption(String value)

Sets the filter clause for the request

Parameters:

value - the filter clause

addFunctionOption

public void addFunctionOption(FunctionOption option)

Adds a function option

Parameters:

option - the function option to add

addHeader

public void addHeader(String header, String value)

Adds a header to this request

Parameters:

header - the name of the header
value - the value of the header

addOrderByOption

protected void addOrderByOption(String value)

Sets the order by clause for the request

Parameters:

value - the order by clause

addQueryOption

public void addQueryOption(QueryOption option)

Adds a query option

Parameters:

option - the query option to add

addSelectOption

protected void addSelectOption(String value)

Sets the select clause for the request

Parameters:

value - the select clause

addSkipOption

protected void addSkipOption(int value)

Sets the skip value for the request

Parameters:

value - of the number of items to skip

addSkipTokenOption

protected void addSkipTokenOption(String skipToken)

Add Skip token for pagination

Parameters:

skipToken -
  • Token for pagination

addTopOption

protected void addTopOption(int value)

Sets the top value for the request

Parameters:

value - the max number of items to return

getClient

public IBaseClient getClient()

Gets the client

Returns:

the client

getDelay

public long getDelay()

Gets delay between retries

Returns:

Delay between retries in seconds

getFunctionOptions

public List getFunctionOptions()

Gets the function options for this request

Returns:

the function options for this request

getHeaders

public List getHeaders()

Gets the headers

Returns:

the headers

getHttpMethod

public HttpMethod getHttpMethod()

Gets the HTTP method

Returns:

the HTTP method

getMaxRedirects

public int getMaxRedirects()

Gets the max redirects

Returns:

Max redirects that a request can take

getMaxRetries

public int getMaxRetries()

Gets max retries

Returns:

Max retries for a request

getOptions

public List

Gets the full list of options for this request

Returns:

the full list of options for this request

getQueryOptions

public List getQueryOptions()

Gets the query options for this request

Returns:

the query options for this request

getRequestUrl

public URL getRequestUrl()

Gets the request URL

Returns:

the request URL

getResponseType

public Class getResponseType()

Gets the response type

Returns:

the response type

getShouldRedirect

public IShouldRedirect getShouldRedirect()

Gets the should redirect callback

Returns:

Callback which is called before redirect

getShouldRetry

public IShouldRetry getShouldRetry()

Gets the should retry callback

Returns:

Callback called before retry

getUseCaches

public boolean getUseCaches()

Gets useCaches parameter

Returns:

the value of useCaches

setDelay

public void setDelay(long delay)

Sets the delay in seconds between retires

Parameters:

delay - Delay in seconds between retries

setHttpMethod

public void setHttpMethod(HttpMethod httpMethod)

Sets the HTTP method

Parameters:

httpMethod - the HTTP method

setMaxRedirects

public void setMaxRedirects(int maxRedirects)

Sets the max redirects

Parameters:

maxRedirects - Max redirects that a request can take

setMaxRetries

public void setMaxRetries(int maxRetries)

Sets the max retries

Parameters:

maxRetries - Max retries for a request

setShouldRedirect

public void setShouldRedirect(IShouldRedirect shouldRedirect)

Sets the should redirect callback

Parameters:

shouldRedirect - Callback called before doing a redirect

setShouldRetry

public void setShouldRetry(IShouldRetry shouldretry)

Sets the should retry callback

Parameters:

shouldretry - The callback called before retry

setUseCaches

public void setUseCaches(boolean useCaches)

Sets useCaches parameter to cache the response

Parameters:

useCaches - the value of useCaches

withHttpMethod

public IHttpRequest withHttpMethod(HttpMethod httpMethod)

Sets the HTTP method and returns the current request

Parameters:

httpMethod - the HTTP method

Returns:

the current request

Applies to