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

package tsptest.errormodel;

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.HttpResponseException;
import com.azure.core.http.rest.RequestOptions;
import com.azure.core.http.rest.Response;
import com.azure.core.util.BinaryData;
import tsptest.errormodel.implementation.ErrorOpsImpl;
import tsptest.errormodel.models.BadResponseErrorException;
import tsptest.errormodel.models.BatchErrorException;
import tsptest.errormodel.models.Diagnostic;

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

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

    /**
     * The read operation.
     * <p><strong>Response Body Schema</strong></p>
     * 
     * <pre>
     * {@code
     * {
     *     name: String (Required)
     *     error (Required): {
     *         code: String (Required)
     *         message: String (Required)
     *         target: String (Optional)
     *         details (Optional): [
     *             (recursive schema, see above)
     *         ]
     *         innererror (Optional): {
     *             code: String (Optional)
     *             innererror (Optional): (recursive schema, see innererror above)
     *         }
     *     }
     *     subError (Required): {
     *         code: String (Required)
     *         message: String (Required)
     *         target: String (Optional)
     *         details (Optional): [
     *             (recursive schema, see above)
     *         ]
     *         innererror (Optional): (recursive schema, see innererror above)
     *         subCode: String (Required)
     *     }
     * }
     * }
     * </pre>
     * 
     * @param requestOptions The options to configure the HTTP request before HTTP client sends it.
     * @throws BatchErrorException thrown if the request is rejected by server.
     * @throws BadResponseErrorException thrown if the request is rejected by server on status code 400.
     * @throws HttpResponseException thrown if the request is rejected by server on status code 404.
     * @return the response body along with {@link Response}.
     */
    @Generated
    @ServiceMethod(returns = ReturnType.SINGLE)
    public Response<BinaryData> readWithResponse(RequestOptions requestOptions) {
        return this.serviceClient.readWithResponse(requestOptions);
    }

    /**
     * The read operation.
     * 
     * @throws BatchErrorException thrown if the request is rejected by server.
     * @throws BadResponseErrorException thrown if the request is rejected by server on status code 400.
     * @throws HttpResponseException thrown if the request is rejected by server on status code 404.
     * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent.
     * @return the response.
     */
    @Generated
    @ServiceMethod(returns = ReturnType.SINGLE)
    public Diagnostic read() {
        // Generated convenience method for readWithResponse
        RequestOptions requestOptions = new RequestOptions();
        return readWithResponse(requestOptions).getValue().toObject(Diagnostic.class);
    }
}
