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

package com.azure.resourcemanager.changeanalysis.implementation;

import com.azure.core.http.rest.PagedIterable;
import com.azure.core.util.Context;
import com.azure.core.util.logging.ClientLogger;
import com.azure.resourcemanager.changeanalysis.fluent.ChangesClient;
import com.azure.resourcemanager.changeanalysis.fluent.models.ChangeInner;
import com.azure.resourcemanager.changeanalysis.models.Change;
import com.azure.resourcemanager.changeanalysis.models.Changes;
import java.time.OffsetDateTime;

public final class ChangesImpl implements Changes {
    private static final ClientLogger LOGGER = new ClientLogger(ChangesImpl.class);

    private final ChangesClient innerClient;

    private final com.azure.resourcemanager.changeanalysis.AzureChangeAnalysisManager serviceManager;

    public ChangesImpl(
        ChangesClient innerClient, com.azure.resourcemanager.changeanalysis.AzureChangeAnalysisManager serviceManager) {
        this.innerClient = innerClient;
        this.serviceManager = serviceManager;
    }

    public PagedIterable<Change> listByResourceGroup(
        String resourceGroupName, OffsetDateTime startTime, OffsetDateTime endTime) {
        PagedIterable<ChangeInner> inner =
            this.serviceClient().listByResourceGroup(resourceGroupName, startTime, endTime);
        return Utils.mapPage(inner, inner1 -> new ChangeImpl(inner1, this.manager()));
    }

    public PagedIterable<Change> listByResourceGroup(
        String resourceGroupName, OffsetDateTime startTime, OffsetDateTime endTime, String skipToken, Context context) {
        PagedIterable<ChangeInner> inner =
            this.serviceClient().listByResourceGroup(resourceGroupName, startTime, endTime, skipToken, context);
        return Utils.mapPage(inner, inner1 -> new ChangeImpl(inner1, this.manager()));
    }

    public PagedIterable<Change> list(OffsetDateTime startTime, OffsetDateTime endTime) {
        PagedIterable<ChangeInner> inner = this.serviceClient().list(startTime, endTime);
        return Utils.mapPage(inner, inner1 -> new ChangeImpl(inner1, this.manager()));
    }

    public PagedIterable<Change> list(
        OffsetDateTime startTime, OffsetDateTime endTime, String skipToken, Context context) {
        PagedIterable<ChangeInner> inner = this.serviceClient().list(startTime, endTime, skipToken, context);
        return Utils.mapPage(inner, inner1 -> new ChangeImpl(inner1, this.manager()));
    }

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

    private com.azure.resourcemanager.changeanalysis.AzureChangeAnalysisManager manager() {
        return this.serviceManager;
    }
}
