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

package com.azure.resourcemanager.automation.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.automation.fluent.NodeReportsClient;
import com.azure.resourcemanager.automation.fluent.models.DscNodeReportInner;
import com.azure.resourcemanager.automation.models.DscNodeReport;
import com.azure.resourcemanager.automation.models.NodeReports;

public final class NodeReportsImpl implements NodeReports {
    private static final ClientLogger LOGGER = new ClientLogger(NodeReportsImpl.class);

    private final NodeReportsClient innerClient;

    private final com.azure.resourcemanager.automation.AutomationManager serviceManager;

    public NodeReportsImpl(
        NodeReportsClient innerClient, com.azure.resourcemanager.automation.AutomationManager serviceManager) {
        this.innerClient = innerClient;
        this.serviceManager = serviceManager;
    }

    public PagedIterable<DscNodeReport> listByNode(
        String resourceGroupName, String automationAccountName, String nodeId) {
        PagedIterable<DscNodeReportInner> inner =
            this.serviceClient().listByNode(resourceGroupName, automationAccountName, nodeId);
        return Utils.mapPage(inner, inner1 -> new DscNodeReportImpl(inner1, this.manager()));
    }

    public PagedIterable<DscNodeReport> listByNode(
        String resourceGroupName, String automationAccountName, String nodeId, String filter, Context context) {
        PagedIterable<DscNodeReportInner> inner =
            this.serviceClient().listByNode(resourceGroupName, automationAccountName, nodeId, filter, context);
        return Utils.mapPage(inner, inner1 -> new DscNodeReportImpl(inner1, this.manager()));
    }

    public DscNodeReport get(String resourceGroupName, String automationAccountName, String nodeId, String reportId) {
        DscNodeReportInner inner = this.serviceClient().get(resourceGroupName, automationAccountName, nodeId, reportId);
        if (inner != null) {
            return new DscNodeReportImpl(inner, this.manager());
        } else {
            return null;
        }
    }

    public Response<DscNodeReport> getWithResponse(
        String resourceGroupName, String automationAccountName, String nodeId, String reportId, Context context) {
        Response<DscNodeReportInner> inner =
            this.serviceClient().getWithResponse(resourceGroupName, automationAccountName, nodeId, reportId, context);
        if (inner != null) {
            return new SimpleResponse<>(
                inner.getRequest(),
                inner.getStatusCode(),
                inner.getHeaders(),
                new DscNodeReportImpl(inner.getValue(), this.manager()));
        } else {
            return null;
        }
    }

    public Object getContent(String resourceGroupName, String automationAccountName, String nodeId, String reportId) {
        return this.serviceClient().getContent(resourceGroupName, automationAccountName, nodeId, reportId);
    }

    public Response<Object> getContentWithResponse(
        String resourceGroupName, String automationAccountName, String nodeId, String reportId, Context context) {
        return this
            .serviceClient()
            .getContentWithResponse(resourceGroupName, automationAccountName, nodeId, reportId, context);
    }

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

    private com.azure.resourcemanager.automation.AutomationManager manager() {
        return this.serviceManager;
    }
}
