

package com.microsoft.azure.management.monitor.v2018_09_01.implementation;

import com.microsoft.azure.AzureEnvironment;
import com.microsoft.azure.AzureResponseBuilder;
import com.microsoft.azure.credentials.AzureTokenCredentials;
import com.microsoft.azure.management.apigeneration.Beta;
import com.microsoft.azure.management.apigeneration.Beta.SinceVersion;
import com.microsoft.azure.arm.resources.AzureConfigurable;
import com.microsoft.azure.serializer.AzureJacksonAdapter;
import com.microsoft.rest.RestClient;
import com.microsoft.azure.management.monitor.v2018_09_01.ActionGroups;
import com.microsoft.azure.management.monitor.v2018_09_01.MetricBaselines;
import com.microsoft.azure.management.monitor.v2018_09_01.Baselines;
import com.microsoft.azure.arm.resources.implementation.AzureConfigurableCoreImpl;
import com.microsoft.azure.arm.resources.implementation.ManagerCore;

/**
 * Entry point to Azure Monitor resource management.
 */
public final class MonitorManager extends ManagerCore<MonitorManager, MonitorManagementClientImpl> {
    private ActionGroups actionGroups;
    private MetricBaselines metricBaselines;
    private Baselines baselines;
    /**
    * Get a Configurable instance that can be used to create MonitorManager with optional configuration.
    *
    * @return the instance allowing configurations
    */
    public static Configurable configure() {
        return new MonitorManager.ConfigurableImpl();
    }
    /**
    * Creates an instance of MonitorManager that exposes Monitor resource management API entry points.
    *
    * @param credentials the credentials to use
    * @param subscriptionId the subscription UUID
    * @return the MonitorManager
    */
    public static MonitorManager authenticate(AzureTokenCredentials credentials, String subscriptionId) {
        return new MonitorManager(new RestClient.Builder()
            .withBaseUrl(credentials.environment(), AzureEnvironment.Endpoint.RESOURCE_MANAGER)
            .withCredentials(credentials)
            .withSerializerAdapter(new AzureJacksonAdapter())
            .withResponseBuilderFactory(new AzureResponseBuilder.Factory())
            .build(), subscriptionId);
    }
    /**
    * Creates an instance of MonitorManager that exposes Monitor resource management API entry points.
    *
    * @param restClient the RestClient to be used for API calls.
    * @param subscriptionId the subscription UUID
    * @return the MonitorManager
    */
    public static MonitorManager authenticate(RestClient restClient, String subscriptionId) {
        return new MonitorManager(restClient, subscriptionId);
    }
    /**
    * The interface allowing configurations to be set.
    */
    public interface Configurable extends AzureConfigurable<Configurable> {
        /**
        * Creates an instance of MonitorManager that exposes Monitor management API entry points.
        *
        * @param credentials the credentials to use
        * @param subscriptionId the subscription UUID
        * @return the interface exposing Monitor management API entry points that work across subscriptions
        */
        MonitorManager authenticate(AzureTokenCredentials credentials, String subscriptionId);
    }

    /**
     * @return Entry point to manage ActionGroups.
     */
    public ActionGroups actionGroups() {
        if (this.actionGroups == null) {
            this.actionGroups = new ActionGroupsImpl(this);
        }
        return this.actionGroups;
    }

    /**
     * @return Entry point to manage MetricBaselines.
     */
    public MetricBaselines metricBaselines() {
        if (this.metricBaselines == null) {
            this.metricBaselines = new MetricBaselinesImpl(this);
        }
        return this.metricBaselines;
    }

    /**
     * @return Entry point to manage Baselines.
     */
    public Baselines baselines() {
        if (this.baselines == null) {
            this.baselines = new BaselinesImpl(this);
        }
        return this.baselines;
    }

    /**
    * The implementation for Configurable interface.
    */
    private static final class ConfigurableImpl extends AzureConfigurableCoreImpl<Configurable> implements Configurable {
        public MonitorManager authenticate(AzureTokenCredentials credentials, String subscriptionId) {
           return MonitorManager.authenticate(buildRestClient(credentials), subscriptionId);
        }
     }
    private MonitorManager(RestClient restClient, String subscriptionId) {
        super(
            restClient,
            subscriptionId,
            new MonitorManagementClientImpl(restClient).withSubscriptionId(subscriptionId));
    }
}
