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

package com.azure.resourcemanager.maintenance.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.maintenance.fluent.PublicMaintenanceConfigurationsClient;
import com.azure.resourcemanager.maintenance.fluent.models.MaintenanceConfigurationInner;
import com.azure.resourcemanager.maintenance.models.MaintenanceConfiguration;
import com.azure.resourcemanager.maintenance.models.PublicMaintenanceConfigurations;

public final class PublicMaintenanceConfigurationsImpl implements PublicMaintenanceConfigurations {
    private static final ClientLogger LOGGER = new ClientLogger(PublicMaintenanceConfigurationsImpl.class);

    private final PublicMaintenanceConfigurationsClient innerClient;

    private final com.azure.resourcemanager.maintenance.MaintenanceManager serviceManager;

    public PublicMaintenanceConfigurationsImpl(
        PublicMaintenanceConfigurationsClient innerClient,
        com.azure.resourcemanager.maintenance.MaintenanceManager serviceManager) {
        this.innerClient = innerClient;
        this.serviceManager = serviceManager;
    }

    public PagedIterable<MaintenanceConfiguration> list() {
        PagedIterable<MaintenanceConfigurationInner> inner = this.serviceClient().list();
        return Utils.mapPage(inner, inner1 -> new MaintenanceConfigurationImpl(inner1, this.manager()));
    }

    public PagedIterable<MaintenanceConfiguration> list(Context context) {
        PagedIterable<MaintenanceConfigurationInner> inner = this.serviceClient().list(context);
        return Utils.mapPage(inner, inner1 -> new MaintenanceConfigurationImpl(inner1, this.manager()));
    }

    public Response<MaintenanceConfiguration> getWithResponse(String resourceName, Context context) {
        Response<MaintenanceConfigurationInner> inner = this.serviceClient().getWithResponse(resourceName, context);
        if (inner != null) {
            return new SimpleResponse<>(
                inner.getRequest(),
                inner.getStatusCode(),
                inner.getHeaders(),
                new MaintenanceConfigurationImpl(inner.getValue(), this.manager()));
        } else {
            return null;
        }
    }

    public MaintenanceConfiguration get(String resourceName) {
        MaintenanceConfigurationInner inner = this.serviceClient().get(resourceName);
        if (inner != null) {
            return new MaintenanceConfigurationImpl(inner, this.manager());
        } else {
            return null;
        }
    }

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

    private com.azure.resourcemanager.maintenance.MaintenanceManager manager() {
        return this.serviceManager;
    }
}
