// 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.models;

import com.azure.core.annotation.Fluent;
import com.azure.core.util.logging.ClientLogger;
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;

/** Parameters supplied to the CreateOrUpdate Environment operation. */
@JsonTypeInfo(
    use = JsonTypeInfo.Id.NAME,
    include = JsonTypeInfo.As.PROPERTY,
    property = "kind",
    defaultImpl = EnvironmentCreateOrUpdateParameters.class)
@JsonTypeName("EnvironmentCreateOrUpdateParameters")
@JsonSubTypes({
    @JsonSubTypes.Type(name = "Gen1", value = Gen1EnvironmentCreateOrUpdateParameters.class),
    @JsonSubTypes.Type(name = "Gen2", value = Gen2EnvironmentCreateOrUpdateParameters.class)
})
@Fluent
public class EnvironmentCreateOrUpdateParameters extends CreateOrUpdateTrackedResourceProperties {
    /*
     * 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 EnvironmentCreateOrUpdateParameters class. */
    public EnvironmentCreateOrUpdateParameters() {
    }

    /**
     * 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 EnvironmentCreateOrUpdateParameters object itself.
     */
    public EnvironmentCreateOrUpdateParameters withSku(Sku sku) {
        this.sku = sku;
        return this;
    }

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

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

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

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