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

package com.azure.resourcemanager.recoveryservicesbackup.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.recoveryservicesbackup.fluent.BackupStatusClient;
import com.azure.resourcemanager.recoveryservicesbackup.fluent.models.BackupStatusResponseInner;
import com.azure.resourcemanager.recoveryservicesbackup.models.BackupStatus;
import com.azure.resourcemanager.recoveryservicesbackup.models.BackupStatusRequest;
import com.azure.resourcemanager.recoveryservicesbackup.models.BackupStatusResponse;

public final class BackupStatusImpl implements BackupStatus {
    private static final ClientLogger LOGGER = new ClientLogger(BackupStatusImpl.class);

    private final BackupStatusClient innerClient;

    private final com.azure.resourcemanager.recoveryservicesbackup.RecoveryServicesBackupManager serviceManager;

    public BackupStatusImpl(
        BackupStatusClient innerClient,
        com.azure.resourcemanager.recoveryservicesbackup.RecoveryServicesBackupManager serviceManager) {
        this.innerClient = innerClient;
        this.serviceManager = serviceManager;
    }

    public Response<BackupStatusResponse> getWithResponse(
        String azureRegion, BackupStatusRequest parameters, Context context) {
        Response<BackupStatusResponseInner> inner =
            this.serviceClient().getWithResponse(azureRegion, parameters, context);
        if (inner != null) {
            return new SimpleResponse<>(
                inner.getRequest(),
                inner.getStatusCode(),
                inner.getHeaders(),
                new BackupStatusResponseImpl(inner.getValue(), this.manager()));
        } else {
            return null;
        }
    }

    public BackupStatusResponse get(String azureRegion, BackupStatusRequest parameters) {
        BackupStatusResponseInner inner = this.serviceClient().get(azureRegion, parameters);
        if (inner != null) {
            return new BackupStatusResponseImpl(inner, this.manager());
        } else {
            return null;
        }
    }

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

    private com.azure.resourcemanager.recoveryservicesbackup.RecoveryServicesBackupManager manager() {
        return this.serviceManager;
    }
}
