// 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.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.FluxConfigOperationStatusClient;
import com.azure.resourcemanager.kubernetesconfiguration.fluent.models.OperationStatusResultInner;
import com.azure.resourcemanager.kubernetesconfiguration.models.FluxConfigOperationStatus;
import com.azure.resourcemanager.kubernetesconfiguration.models.OperationStatusResult;

public final class FluxConfigOperationStatusImpl implements FluxConfigOperationStatus {
    private static final ClientLogger LOGGER = new ClientLogger(FluxConfigOperationStatusImpl.class);

    private final FluxConfigOperationStatusClient innerClient;

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

    public FluxConfigOperationStatusImpl(
        FluxConfigOperationStatusClient 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 fluxConfigurationName,
        String operationId,
        Context context) {
        Response<OperationStatusResultInner> inner =
            this
                .serviceClient()
                .getWithResponse(
                    resourceGroupName,
                    clusterRp,
                    clusterResourceName,
                    clusterName,
                    fluxConfigurationName,
                    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 fluxConfigurationName,
        String operationId) {
        OperationStatusResultInner inner =
            this
                .serviceClient()
                .get(
                    resourceGroupName, clusterRp, clusterResourceName, clusterName, fluxConfigurationName, operationId);
        if (inner != null) {
            return new OperationStatusResultImpl(inner, this.manager());
        } else {
            return null;
        }
    }

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

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