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

package com.azure.health.insights.cancerprofiling;

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.RequestOptions;
import com.azure.core.util.BinaryData;
import com.azure.core.util.polling.PollerFlux;
import com.azure.health.insights.cancerprofiling.implementation.CancerProfilingClientImpl;
import com.azure.health.insights.cancerprofiling.models.OncoPhenotypeData;
import com.azure.health.insights.cancerprofiling.models.OncoPhenotypeResult;

/** Initializes a new instance of the asynchronous CancerProfilingClient type. */
@ServiceClient(builder = CancerProfilingClientBuilder.class, isAsync = true)
public final class CancerProfilingAsyncClient {
    @Generated private final CancerProfilingClientImpl serviceClient;

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

    /**
     * Create Onco Phenotype job
     *
     * <p>Creates an Onco Phenotype job with the given request body.
     *
     * <p><strong>Header Parameters</strong>
     *
     * <table border="1">
     *     <caption>Header Parameters</caption>
     *     <tr><th>Name</th><th>Type</th><th>Required</th><th>Description</th></tr>
     *     <tr><td>repeatability-request-id</td><td>String</td><td>No</td><td>Repeatability request ID header</td></tr>
     *     <tr><td>repeatability-first-sent</td><td>String</td><td>No</td><td>Repeatability first sent header as HTTP-date</td></tr>
     * </table>
     *
     * You can add these to a request with {@link RequestOptions#addHeader}
     *
     * <p><strong>Request Body Schema</strong>
     *
     * <pre>{@code
     * {
     *     patients (Required): [
     *          (Required){
     *             id: String (Required)
     *             info (Optional): {
     *                 sex: String(female/male/unspecified) (Optional)
     *                 birthDate: LocalDate (Optional)
     *                 clinicalInfo (Optional): [
     *                      (Optional){
     *                         system: String (Required)
     *                         code: String (Required)
     *                         name: String (Optional)
     *                         value: String (Optional)
     *                     }
     *                 ]
     *             }
     *             data (Optional): [
     *                  (Optional){
     *                     type: String(note/fhirBundle/dicom/genomicSequencing) (Required)
     *                     clinicalType: String(consultation/dischargeSummary/historyAndPhysical/procedure/progress/imaging/laboratory/pathology) (Optional)
     *                     id: String (Required)
     *                     language: String (Optional)
     *                     createdDateTime: OffsetDateTime (Optional)
     *                     content (Required): {
     *                         sourceType: String(inline/reference) (Required)
     *                         value: String (Required)
     *                     }
     *                 }
     *             ]
     *         }
     *     ]
     *     configuration (Optional): {
     *         verbose: Boolean (Optional)
     *         includeEvidence: Boolean (Optional)
     *         inferenceTypes (Optional): [
     *             String(tumorSite/histology/clinicalStageT/clinicalStageN/clinicalStageM/pathologicStageT/pathologicStageN/pathologicStageM) (Optional)
     *         ]
     *         checkForCancerCase: Boolean (Optional)
     *     }
     * }
     * }</pre>
     *
     * <p><strong>Response Body Schema</strong>
     *
     * <pre>{@code
     * {
     *     jobId: String (Required)
     *     createdDateTime: OffsetDateTime (Required)
     *     expirationDateTime: OffsetDateTime (Required)
     *     lastUpdateDateTime: OffsetDateTime (Required)
     *     status: String(notStarted/running/succeeded/failed/partiallyCompleted) (Required)
     *     errors (Optional): [
     *         ResponseError (Optional)
     *     ]
     *     results (Optional): {
     *         patients (Required): [
     *              (Required){
     *                 id: String (Required)
     *                 inferences (Required): [
     *                      (Required){
     *                         type: String(tumorSite/histology/clinicalStageT/clinicalStageN/clinicalStageM/pathologicStageT/pathologicStageN/pathologicStageM) (Required)
     *                         value: String (Required)
     *                         description: String (Optional)
     *                         confidenceScore: Double (Optional)
     *                         evidence (Optional): [
     *                              (Optional){
     *                                 patientDataEvidence (Optional): {
     *                                     id: String (Required)
     *                                     text: String (Optional)
     *                                     offset: int (Required)
     *                                     length: int (Required)
     *                                 }
     *                                 patientInfoEvidence (Optional): {
     *                                     system: String (Required)
     *                                     code: String (Required)
     *                                     name: String (Optional)
     *                                     value: String (Optional)
     *                                 }
     *                                 importance: Double (Optional)
     *                             }
     *                         ]
     *                         caseId: String (Optional)
     *                     }
     *                 ]
     *             }
     *         ]
     *         modelVersion: String (Required)
     *     }
     * }
     * }</pre>
     *
     * @param oncoPhenotypeData The body of the Onco Phenotype request.
     * @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 {@link PollerFlux} for polling of the response for the Onco Phenotype request.
     */
    @Generated
    @ServiceMethod(returns = ReturnType.LONG_RUNNING_OPERATION)
    public PollerFlux<BinaryData, BinaryData> beginInferCancerProfile(
            BinaryData oncoPhenotypeData, RequestOptions requestOptions) {
        return this.serviceClient.beginInferCancerProfileAsync(oncoPhenotypeData, requestOptions);
    }

    /**
     * Create Onco Phenotype job
     *
     * <p>Creates an Onco Phenotype job with the given request body.
     *
     * @param oncoPhenotypeData The body of the Onco Phenotype request.
     * @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 the {@link PollerFlux} for polling of the response for the Onco Phenotype request.
     */
    @Generated
    @ServiceMethod(returns = ReturnType.LONG_RUNNING_OPERATION)
    public PollerFlux<OncoPhenotypeResult, OncoPhenotypeResult> beginInferCancerProfile(
            OncoPhenotypeData oncoPhenotypeData) {
        // Generated convenience method for beginInferCancerProfileWithModel
        RequestOptions requestOptions = new RequestOptions();
        return serviceClient.beginInferCancerProfileWithModelAsync(
                BinaryData.fromObject(oncoPhenotypeData), requestOptions);
    }
}
