// Copyright (c) Microsoft Corporation. All rights reserved.
// Licensed under the MIT License.
// Code generated by Microsoft (R) TypeSpec Code Generator.

package azure.core.page;

import azure.core.page.implementation.PageClientImpl;
import azure.core.page.models.ListItemInputBody;
import azure.core.page.models.ListItemInputExtensibleEnum;
import azure.core.page.models.User;
import com.azure.core.annotation.Generated;
import com.azure.core.annotation.ReturnType;
import com.azure.core.annotation.ServiceClient;
import com.azure.core.annotation.ServiceMethod;
import com.azure.core.exception.ClientAuthenticationException;
import com.azure.core.exception.HttpResponseException;
import com.azure.core.exception.ResourceModifiedException;
import com.azure.core.exception.ResourceNotFoundException;
import com.azure.core.http.rest.PagedIterable;
import com.azure.core.http.rest.RequestOptions;
import com.azure.core.util.BinaryData;

/**
 * Initializes a new instance of the synchronous PageClient type.
 */
@ServiceClient(builder = PageClientBuilder.class)
public final class PageClient {
    @Generated
    private final PageClientImpl serviceClient;

    /**
     * Initializes an instance of PageClient class.
     * 
     * @param serviceClient the service client implementation.
     */
    @Generated
    PageClient(PageClientImpl serviceClient) {
        this.serviceClient = serviceClient;
    }

    /**
     * List with Azure.Core.Page&lt;&gt;.
     * <p><strong>Response Body Schema</strong></p>
     * 
     * <pre>
     * {@code
     * {
     *     id: int (Required)
     *     name: String (Required)
     *     orders (Optional): [
     *          (Optional){
     *             id: int (Required)
     *             userId: int (Required)
     *             detail: String (Required)
     *         }
     *     ]
     *     etag: String (Required)
     * }
     * }
     * </pre>
     * 
     * @param requestOptions The options to configure the HTTP request before HTTP client sends it.
     * @throws HttpResponseException thrown if the request is rejected by server.
     * @throws ClientAuthenticationException thrown if the request is rejected by server on status code 401.
     * @throws ResourceNotFoundException thrown if the request is rejected by server on status code 404.
     * @throws ResourceModifiedException thrown if the request is rejected by server on status code 409.
     * @return paged collection of User items as paginated response with {@link PagedIterable}.
     */
    @Generated
    @ServiceMethod(returns = ReturnType.COLLECTION)
    public PagedIterable<BinaryData> listWithPage(RequestOptions requestOptions) {
        return this.serviceClient.listWithPage(requestOptions);
    }

    /**
     * List with extensible enum parameter Azure.Core.Page&lt;&gt;.
     * <p><strong>Query Parameters</strong></p>
     * <table border="1">
     * <caption>Query Parameters</caption>
     * <tr><th>Name</th><th>Type</th><th>Required</th><th>Description</th></tr>
     * <tr><td>another</td><td>String</td><td>No</td><td>Another query parameter. Allowed values: "First",
     * "Second".</td></tr>
     * </table>
     * You can add these to a request with {@link RequestOptions#addQueryParam}
     * <p><strong>Request Body Schema</strong></p>
     * 
     * <pre>
     * {@code
     * {
     *     inputName: String (Required)
     * }
     * }
     * </pre>
     * 
     * <p><strong>Response Body Schema</strong></p>
     * 
     * <pre>
     * {@code
     * {
     *     id: int (Required)
     *     name: String (Required)
     *     orders (Optional): [
     *          (Optional){
     *             id: int (Required)
     *             userId: int (Required)
     *             detail: String (Required)
     *         }
     *     ]
     *     etag: String (Required)
     * }
     * }
     * </pre>
     * 
     * @param bodyInput The body of the input.
     * @param requestOptions The options to configure the HTTP request before HTTP client sends it.
     * @throws HttpResponseException thrown if the request is rejected by server.
     * @throws ClientAuthenticationException thrown if the request is rejected by server on status code 401.
     * @throws ResourceNotFoundException thrown if the request is rejected by server on status code 404.
     * @throws ResourceModifiedException thrown if the request is rejected by server on status code 409.
     * @return paged collection of User items as paginated response with {@link PagedIterable}.
     */
    @Generated
    @ServiceMethod(returns = ReturnType.COLLECTION)
    public PagedIterable<BinaryData> listWithParameters(BinaryData bodyInput, RequestOptions requestOptions) {
        return this.serviceClient.listWithParameters(bodyInput, requestOptions);
    }

    /**
     * List with custom page model.
     * <p><strong>Response Body Schema</strong></p>
     * 
     * <pre>
     * {@code
     * {
     *     id: int (Required)
     *     name: String (Required)
     *     orders (Optional): [
     *          (Optional){
     *             id: int (Required)
     *             userId: int (Required)
     *             detail: String (Required)
     *         }
     *     ]
     *     etag: String (Required)
     * }
     * }
     * </pre>
     * 
     * @param requestOptions The options to configure the HTTP request before HTTP client sends it.
     * @throws HttpResponseException thrown if the request is rejected by server.
     * @throws ClientAuthenticationException thrown if the request is rejected by server on status code 401.
     * @throws ResourceNotFoundException thrown if the request is rejected by server on status code 404.
     * @throws ResourceModifiedException thrown if the request is rejected by server on status code 409.
     * @return the paginated response with {@link PagedIterable}.
     */
    @Generated
    @ServiceMethod(returns = ReturnType.COLLECTION)
    public PagedIterable<BinaryData> listWithCustomPageModel(RequestOptions requestOptions) {
        return this.serviceClient.listWithCustomPageModel(requestOptions);
    }

    /**
     * List with Azure.Core.Page&lt;&gt;.
     * 
     * @throws HttpResponseException thrown if the request is rejected by server.
     * @throws ClientAuthenticationException thrown if the request is rejected by server on status code 401.
     * @throws ResourceNotFoundException thrown if the request is rejected by server on status code 404.
     * @throws ResourceModifiedException thrown if the request is rejected by server on status code 409.
     * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent.
     * @return paged collection of User items as paginated response with {@link PagedIterable}.
     */
    @Generated
    @ServiceMethod(returns = ReturnType.COLLECTION)
    public PagedIterable<User> listWithPage() {
        // Generated convenience method for listWithPage
        RequestOptions requestOptions = new RequestOptions();
        return serviceClient.listWithPage(requestOptions).mapPage(bodyItemValue -> bodyItemValue.toObject(User.class));
    }

    /**
     * List with extensible enum parameter Azure.Core.Page&lt;&gt;.
     * 
     * @param bodyInput The body of the input.
     * @param another Another query parameter.
     * @throws IllegalArgumentException thrown if parameters fail the validation.
     * @throws HttpResponseException thrown if the request is rejected by server.
     * @throws ClientAuthenticationException thrown if the request is rejected by server on status code 401.
     * @throws ResourceNotFoundException thrown if the request is rejected by server on status code 404.
     * @throws ResourceModifiedException thrown if the request is rejected by server on status code 409.
     * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent.
     * @return paged collection of User items as paginated response with {@link PagedIterable}.
     */
    @Generated
    @ServiceMethod(returns = ReturnType.COLLECTION)
    public PagedIterable<User> listWithParameters(ListItemInputBody bodyInput, ListItemInputExtensibleEnum another) {
        // Generated convenience method for listWithParameters
        RequestOptions requestOptions = new RequestOptions();
        if (another != null) {
            requestOptions.addQueryParam("another", another.toString(), false);
        }
        return serviceClient.listWithParameters(BinaryData.fromObject(bodyInput), requestOptions)
            .mapPage(bodyItemValue -> bodyItemValue.toObject(User.class));
    }

    /**
     * List with extensible enum parameter Azure.Core.Page&lt;&gt;.
     * 
     * @param bodyInput The body of the input.
     * @throws IllegalArgumentException thrown if parameters fail the validation.
     * @throws HttpResponseException thrown if the request is rejected by server.
     * @throws ClientAuthenticationException thrown if the request is rejected by server on status code 401.
     * @throws ResourceNotFoundException thrown if the request is rejected by server on status code 404.
     * @throws ResourceModifiedException thrown if the request is rejected by server on status code 409.
     * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent.
     * @return paged collection of User items as paginated response with {@link PagedIterable}.
     */
    @Generated
    @ServiceMethod(returns = ReturnType.COLLECTION)
    public PagedIterable<User> listWithParameters(ListItemInputBody bodyInput) {
        // Generated convenience method for listWithParameters
        RequestOptions requestOptions = new RequestOptions();
        return serviceClient.listWithParameters(BinaryData.fromObject(bodyInput), requestOptions)
            .mapPage(bodyItemValue -> bodyItemValue.toObject(User.class));
    }

    /**
     * List with custom page model.
     * 
     * @throws HttpResponseException thrown if the request is rejected by server.
     * @throws ClientAuthenticationException thrown if the request is rejected by server on status code 401.
     * @throws ResourceNotFoundException thrown if the request is rejected by server on status code 404.
     * @throws ResourceModifiedException thrown if the request is rejected by server on status code 409.
     * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent.
     * @return the paginated response with {@link PagedIterable}.
     */
    @Generated
    @ServiceMethod(returns = ReturnType.COLLECTION)
    public PagedIterable<User> listWithCustomPageModel() {
        // Generated convenience method for listWithCustomPageModel
        RequestOptions requestOptions = new RequestOptions();
        return serviceClient.listWithCustomPageModel(requestOptions)
            .mapPage(bodyItemValue -> bodyItemValue.toObject(User.class));
    }
}
