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

package com.azure.resourcemanager.recoveryservicessiterecovery.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.recoveryservicessiterecovery.fluent.ReplicationVaultHealthsClient;
import com.azure.resourcemanager.recoveryservicessiterecovery.fluent.models.VaultHealthDetailsInner;
import com.azure.resourcemanager.recoveryservicessiterecovery.models.ReplicationVaultHealths;
import com.azure.resourcemanager.recoveryservicessiterecovery.models.VaultHealthDetails;

public final class ReplicationVaultHealthsImpl implements ReplicationVaultHealths {
    private static final ClientLogger LOGGER = new ClientLogger(ReplicationVaultHealthsImpl.class);

    private final ReplicationVaultHealthsClient innerClient;

    private final com.azure.resourcemanager.recoveryservicessiterecovery.SiteRecoveryManager serviceManager;

    public ReplicationVaultHealthsImpl(
        ReplicationVaultHealthsClient innerClient,
        com.azure.resourcemanager.recoveryservicessiterecovery.SiteRecoveryManager serviceManager) {
        this.innerClient = innerClient;
        this.serviceManager = serviceManager;
    }

    public Response<VaultHealthDetails> getWithResponse(
        String resourceName, String resourceGroupName, Context context) {
        Response<VaultHealthDetailsInner> inner =
            this.serviceClient().getWithResponse(resourceName, resourceGroupName, context);
        if (inner != null) {
            return new SimpleResponse<>(
                inner.getRequest(),
                inner.getStatusCode(),
                inner.getHeaders(),
                new VaultHealthDetailsImpl(inner.getValue(), this.manager()));
        } else {
            return null;
        }
    }

    public VaultHealthDetails get(String resourceName, String resourceGroupName) {
        VaultHealthDetailsInner inner = this.serviceClient().get(resourceName, resourceGroupName);
        if (inner != null) {
            return new VaultHealthDetailsImpl(inner, this.manager());
        } else {
            return null;
        }
    }

    public VaultHealthDetails refresh(String resourceName, String resourceGroupName) {
        VaultHealthDetailsInner inner = this.serviceClient().refresh(resourceName, resourceGroupName);
        if (inner != null) {
            return new VaultHealthDetailsImpl(inner, this.manager());
        } else {
            return null;
        }
    }

    public VaultHealthDetails refresh(String resourceName, String resourceGroupName, Context context) {
        VaultHealthDetailsInner inner = this.serviceClient().refresh(resourceName, resourceGroupName, context);
        if (inner != null) {
            return new VaultHealthDetailsImpl(inner, this.manager());
        } else {
            return null;
        }
    }

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

    private com.azure.resourcemanager.recoveryservicessiterecovery.SiteRecoveryManager manager() {
        return this.serviceManager;
    }
}
