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

package com.azure.resourcemanager.kubernetesconfiguration.implementation;

import com.azure.core.http.rest.PagedIterable;
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.kubernetesconfiguration.fluent.OperationStatusClient;
import com.azure.resourcemanager.kubernetesconfiguration.fluent.models.OperationStatusResultInner;
import com.azure.resourcemanager.kubernetesconfiguration.models.OperationStatus;
import com.azure.resourcemanager.kubernetesconfiguration.models.OperationStatusResult;

public final class OperationStatusImpl implements OperationStatus {
    private static final ClientLogger LOGGER = new ClientLogger(OperationStatusImpl.class);

    private final OperationStatusClient innerClient;

    private final com.azure.resourcemanager.kubernetesconfiguration.SourceControlConfigurationManager serviceManager;

    public OperationStatusImpl(
        OperationStatusClient innerClient,
        com.azure.resourcemanager.kubernetesconfiguration.SourceControlConfigurationManager serviceManager) {
        this.innerClient = innerClient;
        this.serviceManager = serviceManager;
    }

    public Response<OperationStatusResult> getWithResponse(
        String resourceGroupName,
        String clusterRp,
        String clusterResourceName,
        String clusterName,
        String extensionName,
        String operationId,
        Context context) {
        Response<OperationStatusResultInner> inner =
            this
                .serviceClient()
                .getWithResponse(
                    resourceGroupName,
                    clusterRp,
                    clusterResourceName,
                    clusterName,
                    extensionName,
                    operationId,
                    context);
        if (inner != null) {
            return new SimpleResponse<>(
                inner.getRequest(),
                inner.getStatusCode(),
                inner.getHeaders(),
                new OperationStatusResultImpl(inner.getValue(), this.manager()));
        } else {
            return null;
        }
    }

    public OperationStatusResult get(
        String resourceGroupName,
        String clusterRp,
        String clusterResourceName,
        String clusterName,
        String extensionName,
        String operationId) {
        OperationStatusResultInner inner =
            this
                .serviceClient()
                .get(resourceGroupName, clusterRp, clusterResourceName, clusterName, extensionName, operationId);
        if (inner != null) {
            return new OperationStatusResultImpl(inner, this.manager());
        } else {
            return null;
        }
    }

    public PagedIterable<OperationStatusResult> list(
        String resourceGroupName, String clusterRp, String clusterResourceName, String clusterName) {
        PagedIterable<OperationStatusResultInner> inner =
            this.serviceClient().list(resourceGroupName, clusterRp, clusterResourceName, clusterName);
        return Utils.mapPage(inner, inner1 -> new OperationStatusResultImpl(inner1, this.manager()));
    }

    public PagedIterable<OperationStatusResult> list(
        String resourceGroupName, String clusterRp, String clusterResourceName, String clusterName, Context context) {
        PagedIterable<OperationStatusResultInner> inner =
            this.serviceClient().list(resourceGroupName, clusterRp, clusterResourceName, clusterName, context);
        return Utils.mapPage(inner, inner1 -> new OperationStatusResultImpl(inner1, this.manager()));
    }

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

    private com.azure.resourcemanager.kubernetesconfiguration.SourceControlConfigurationManager manager() {
        return this.serviceManager;
    }
}
