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

package com.azure.resourcemanager.logz.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.logz.fluent.MonitorOperationsClient;
import com.azure.resourcemanager.logz.fluent.models.VMExtensionPayloadInner;
import com.azure.resourcemanager.logz.fluent.models.VMResourcesInner;
import com.azure.resourcemanager.logz.models.MonitorOperations;
import com.azure.resourcemanager.logz.models.VMExtensionPayload;
import com.azure.resourcemanager.logz.models.VMHostUpdateRequest;
import com.azure.resourcemanager.logz.models.VMResources;

public final class MonitorOperationsImpl implements MonitorOperations {
    private static final ClientLogger LOGGER = new ClientLogger(MonitorOperationsImpl.class);

    private final MonitorOperationsClient innerClient;

    private final com.azure.resourcemanager.logz.LogzManager serviceManager;

    public MonitorOperationsImpl(
        MonitorOperationsClient innerClient, com.azure.resourcemanager.logz.LogzManager serviceManager) {
        this.innerClient = innerClient;
        this.serviceManager = serviceManager;
    }

    public Response<VMExtensionPayload> vMHostPayloadWithResponse(
        String resourceGroupName, String monitorName, Context context) {
        Response<VMExtensionPayloadInner> inner =
            this.serviceClient().vMHostPayloadWithResponse(resourceGroupName, monitorName, context);
        if (inner != null) {
            return new SimpleResponse<>(
                inner.getRequest(),
                inner.getStatusCode(),
                inner.getHeaders(),
                new VMExtensionPayloadImpl(inner.getValue(), this.manager()));
        } else {
            return null;
        }
    }

    public VMExtensionPayload vMHostPayload(String resourceGroupName, String monitorName) {
        VMExtensionPayloadInner inner = this.serviceClient().vMHostPayload(resourceGroupName, monitorName);
        if (inner != null) {
            return new VMExtensionPayloadImpl(inner, this.manager());
        } else {
            return null;
        }
    }

    public PagedIterable<VMResources> listVmHostUpdate(String resourceGroupName, String monitorName) {
        PagedIterable<VMResourcesInner> inner = this.serviceClient().listVmHostUpdate(resourceGroupName, monitorName);
        return Utils.mapPage(inner, inner1 -> new VMResourcesImpl(inner1, this.manager()));
    }

    public PagedIterable<VMResources> listVmHostUpdate(
        String resourceGroupName, String monitorName, VMHostUpdateRequest body, Context context) {
        PagedIterable<VMResourcesInner> inner =
            this.serviceClient().listVmHostUpdate(resourceGroupName, monitorName, body, context);
        return Utils.mapPage(inner, inner1 -> new VMResourcesImpl(inner1, this.manager()));
    }

    public PagedIterable<VMResources> listVMHosts(String resourceGroupName, String monitorName) {
        PagedIterable<VMResourcesInner> inner = this.serviceClient().listVMHosts(resourceGroupName, monitorName);
        return Utils.mapPage(inner, inner1 -> new VMResourcesImpl(inner1, this.manager()));
    }

    public PagedIterable<VMResources> listVMHosts(String resourceGroupName, String monitorName, Context context) {
        PagedIterable<VMResourcesInner> inner =
            this.serviceClient().listVMHosts(resourceGroupName, monitorName, context);
        return Utils.mapPage(inner, inner1 -> new VMResourcesImpl(inner1, this.manager()));
    }

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

    private com.azure.resourcemanager.logz.LogzManager manager() {
        return this.serviceManager;
    }
}
