// 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.ResourceChangesClient;
import com.azure.resourcemanager.changeanalysis.fluent.models.ChangeInner;
import com.azure.resourcemanager.changeanalysis.models.Change;
import com.azure.resourcemanager.changeanalysis.models.ResourceChanges;
import java.time.OffsetDateTime;

public final class ResourceChangesImpl implements ResourceChanges {
    private static final ClientLogger LOGGER = new ClientLogger(ResourceChangesImpl.class);

    private final ResourceChangesClient innerClient;

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

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

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

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

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

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