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

package com.azure.resourcemanager.kusto.implementation;

import com.azure.core.http.rest.Response;
import com.azure.core.http.rest.SimpleResponse;
import com.azure.core.util.Context;
import com.azure.core.util.logging.ClientLogger;
import com.azure.resourcemanager.kusto.fluent.OperationsResultsClient;
import com.azure.resourcemanager.kusto.fluent.models.OperationResultInner;
import com.azure.resourcemanager.kusto.models.OperationResult;
import com.azure.resourcemanager.kusto.models.OperationsResults;

public final class OperationsResultsImpl implements OperationsResults {
    private static final ClientLogger LOGGER = new ClientLogger(OperationsResultsImpl.class);

    private final OperationsResultsClient innerClient;

    private final com.azure.resourcemanager.kusto.KustoManager serviceManager;

    public OperationsResultsImpl(
        OperationsResultsClient innerClient, com.azure.resourcemanager.kusto.KustoManager serviceManager) {
        this.innerClient = innerClient;
        this.serviceManager = serviceManager;
    }

    public Response<OperationResult> getWithResponse(String location, String operationId, Context context) {
        Response<OperationResultInner> inner = this.serviceClient().getWithResponse(location, operationId, context);
        if (inner != null) {
            return new SimpleResponse<>(
                inner.getRequest(),
                inner.getStatusCode(),
                inner.getHeaders(),
                new OperationResultImpl(inner.getValue(), this.manager()));
        } else {
            return null;
        }
    }

    public OperationResult get(String location, String operationId) {
        OperationResultInner inner = this.serviceClient().get(location, operationId);
        if (inner != null) {
            return new OperationResultImpl(inner, this.manager());
        } else {
            return null;
        }
    }

    private OperationsResultsClient serviceClient() {
        return this.innerClient;
    }

    private com.azure.resourcemanager.kusto.KustoManager manager() {
        return this.serviceManager;
    }
}
