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

package com.azure.resourcemanager.timeseriesinsights.fluent.models;

import com.azure.core.annotation.Fluent;
import com.azure.core.management.Resource;
import com.azure.core.util.logging.ClientLogger;
import com.azure.resourcemanager.timeseriesinsights.models.Gen1EnvironmentResource;
import com.azure.resourcemanager.timeseriesinsights.models.Gen2EnvironmentResource;
import com.azure.resourcemanager.timeseriesinsights.models.Sku;
import com.fasterxml.jackson.annotation.JsonProperty;
import com.fasterxml.jackson.annotation.JsonSubTypes;
import com.fasterxml.jackson.annotation.JsonTypeInfo;
import com.fasterxml.jackson.annotation.JsonTypeName;
import java.util.Map;

/**
 * An environment is a set of time-series data available for query, and is the top level Azure Time Series Insights
 * resource.
 */
@JsonTypeInfo(
    use = JsonTypeInfo.Id.NAME,
    include = JsonTypeInfo.As.PROPERTY,
    property = "kind",
    defaultImpl = EnvironmentResourceInner.class)
@JsonTypeName("EnvironmentResource")
@JsonSubTypes({
    @JsonSubTypes.Type(name = "Gen1", value = Gen1EnvironmentResource.class),
    @JsonSubTypes.Type(name = "Gen2", value = Gen2EnvironmentResource.class)
})
@Fluent
public class EnvironmentResourceInner extends Resource {
    /*
     * The sku determines the type of environment, either Gen1 (S1 or S2) or Gen2 (L1). For Gen1 environments the sku
     * determines the capacity of the environment, the ingress rate, and the billing rate.
     */
    @JsonProperty(value = "sku", required = true)
    private Sku sku;

    /** Creates an instance of EnvironmentResourceInner class. */
    public EnvironmentResourceInner() {
    }

    /**
     * Get the sku property: The sku determines the type of environment, either Gen1 (S1 or S2) or Gen2 (L1). For Gen1
     * environments the sku determines the capacity of the environment, the ingress rate, and the billing rate.
     *
     * @return the sku value.
     */
    public Sku sku() {
        return this.sku;
    }

    /**
     * Set the sku property: The sku determines the type of environment, either Gen1 (S1 or S2) or Gen2 (L1). For Gen1
     * environments the sku determines the capacity of the environment, the ingress rate, and the billing rate.
     *
     * @param sku the sku value to set.
     * @return the EnvironmentResourceInner object itself.
     */
    public EnvironmentResourceInner withSku(Sku sku) {
        this.sku = sku;
        return this;
    }

    /** {@inheritDoc} */
    @Override
    public EnvironmentResourceInner withLocation(String location) {
        super.withLocation(location);
        return this;
    }

    /** {@inheritDoc} */
    @Override
    public EnvironmentResourceInner withTags(Map<String, String> tags) {
        super.withTags(tags);
        return this;
    }

    /**
     * Validates the instance.
     *
     * @throws IllegalArgumentException thrown if the instance is not valid.
     */
    public void validate() {
        if (sku() == null) {
            throw LOGGER
                .logExceptionAsError(
                    new IllegalArgumentException("Missing required property sku in model EnvironmentResourceInner"));
        } else {
            sku().validate();
        }
    }

    private static final ClientLogger LOGGER = new ClientLogger(EnvironmentResourceInner.class);
}
