com.microsoft.graph.requests.extensions.TimeOffCollectionRequest Maven / Gradle / Ivy
// Template Source: BaseEntityCollectionRequest.java.tt
// ------------------------------------------------------------------------------
// Copyright (c) Microsoft Corporation. All Rights Reserved. Licensed under the MIT License. See License in the project root for license information.
// ------------------------------------------------------------------------------
package com.microsoft.graph.requests.extensions;
import com.microsoft.graph.http.IRequestBuilder;
import com.microsoft.graph.core.ClientException;
import com.microsoft.graph.concurrency.ICallback;
import com.microsoft.graph.models.extensions.Schedule;
import com.microsoft.graph.models.extensions.TimeOff;
import java.util.Arrays;
import java.util.EnumSet;
import com.microsoft.graph.options.QueryOption;
import com.microsoft.graph.core.IBaseClient;
import com.microsoft.graph.http.BaseCollectionRequest;
import com.microsoft.graph.concurrency.IExecutors;
import com.microsoft.graph.requests.extensions.ITimeOffCollectionPage;
import com.microsoft.graph.requests.extensions.TimeOffCollectionResponse;
import com.microsoft.graph.requests.extensions.ITimeOffCollectionRequestBuilder;
import com.microsoft.graph.requests.extensions.ITimeOffCollectionRequest;
import com.microsoft.graph.requests.extensions.TimeOffCollectionPage;
// **NOTE** This file was generated by a tool and any changes will be overwritten.
/**
* The class for the Time Off Collection Request.
*/
public class TimeOffCollectionRequest extends BaseCollectionRequest implements ITimeOffCollectionRequest {
/**
* The request builder for this collection of TimeOff
*
* @param requestUrl the request URL
* @param client the service client
* @param requestOptions the options for this request
*/
public TimeOffCollectionRequest(final String requestUrl, IBaseClient client, final java.util.List extends com.microsoft.graph.options.Option> requestOptions) {
super(requestUrl, client, requestOptions, TimeOffCollectionResponse.class, ITimeOffCollectionPage.class);
}
public void get(final ICallback super ITimeOffCollectionPage> callback) {
final IExecutors executors = getBaseRequest().getClient().getExecutors();
executors.performOnBackground(new Runnable() {
@Override
public void run() {
try {
executors.performOnForeground(get(), callback);
} catch (final ClientException e) {
executors.performOnForeground(e, callback);
}
}
});
}
public ITimeOffCollectionPage get() throws ClientException {
final TimeOffCollectionResponse response = send();
return buildFromResponse(response);
}
public void post(final TimeOff newTimeOff, final ICallback super TimeOff> callback) {
final String requestUrl = getBaseRequest().getRequestUrl().toString();
new TimeOffRequestBuilder(requestUrl, getBaseRequest().getClient(), /* Options */ null)
.buildRequest(getBaseRequest().getHeaders())
.post(newTimeOff, callback);
}
public TimeOff post(final TimeOff newTimeOff) throws ClientException {
final String requestUrl = getBaseRequest().getRequestUrl().toString();
return new TimeOffRequestBuilder(requestUrl, getBaseRequest().getClient(), /* Options */ null)
.buildRequest(getBaseRequest().getHeaders())
.post(newTimeOff);
}
/**
* Sets the expand clause for the request
*
* @param value the expand clause
* @return the updated request
*/
public ITimeOffCollectionRequest expand(final String value) {
addQueryOption(new com.microsoft.graph.options.QueryOption("$expand", value));
return (TimeOffCollectionRequest)this;
}
/**
* Sets the filter clause for the request
*
* @param value the filter clause
* @return the updated request
*/
public ITimeOffCollectionRequest filter(final String value) {
addQueryOption(new com.microsoft.graph.options.QueryOption("$filter", value));
return (TimeOffCollectionRequest)this;
}
/**
* Sets the order by clause for the request
*
* @param value the order by clause
* @return the updated request
*/
public ITimeOffCollectionRequest orderBy(final String value) {
addQueryOption(new com.microsoft.graph.options.QueryOption("$orderby", value));
return (TimeOffCollectionRequest)this;
}
/**
* Sets the select clause for the request
*
* @param value the select clause
* @return the updated request
*/
public ITimeOffCollectionRequest select(final String value) {
addQueryOption(new com.microsoft.graph.options.QueryOption("$select", value));
return (TimeOffCollectionRequest)this;
}
/**
* Sets the top value for the request
*
* @param value the max number of items to return
* @return the updated request
*/
public ITimeOffCollectionRequest top(final int value) {
addQueryOption(new com.microsoft.graph.options.QueryOption("$top", value + ""));
return (TimeOffCollectionRequest)this;
}
/**
* Sets the skip value for the request
*
* @param value of the number of items to skip
* @return the updated request
*/
public ITimeOffCollectionRequest skip(final int value) {
addQueryOption(new com.microsoft.graph.options.QueryOption("$skip", value + ""));
return (TimeOffCollectionRequest)this;
}
/**
* Add Skip token for pagination
* @param skipToken - Token for pagination
* @return the updated request
*/
public ITimeOffCollectionRequest skipToken(final String skipToken) {
addQueryOption(new QueryOption("$skiptoken", skipToken));
return (ITimeOffCollectionRequest)this;
}
public ITimeOffCollectionPage buildFromResponse(final TimeOffCollectionResponse response) {
final ITimeOffCollectionRequestBuilder builder;
if (response.nextLink != null) {
builder = new TimeOffCollectionRequestBuilder(response.nextLink, getBaseRequest().getClient(), /* options */ null);
} else {
builder = null;
}
final TimeOffCollectionPage page = new TimeOffCollectionPage(response, builder);
page.setRawObject(response.getSerializer(), response.getRawObject());
return page;
}
}