// 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.azure.resourcemanager.timeseriesinsights.fluent.models.EnvironmentResourceInner;
import com.azure.resourcemanager.timeseriesinsights.fluent.models.Gen1EnvironmentResourceProperties;
import com.fasterxml.jackson.annotation.JsonProperty;
import com.fasterxml.jackson.annotation.JsonTypeInfo;
import com.fasterxml.jackson.annotation.JsonTypeName;
import java.time.Duration;
import java.time.OffsetDateTime;
import java.util.List;
import java.util.Map;
import java.util.UUID;

/**
 * An environment is a set of time-series data available for query, and is the top level Azure Time Series Insights
 * resource. Gen1 environments have data retention limits.
 */
@JsonTypeInfo(use = JsonTypeInfo.Id.NAME, include = JsonTypeInfo.As.PROPERTY, property = "kind")
@JsonTypeName("Gen1")
@Fluent
public final class Gen1EnvironmentResource extends EnvironmentResourceInner {
    /*
     * Properties of the Gen1 environment.
     */
    @JsonProperty(value = "properties", required = true)
    private Gen1EnvironmentResourceProperties innerProperties = new Gen1EnvironmentResourceProperties();

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

    /**
     * Get the innerProperties property: Properties of the Gen1 environment.
     *
     * @return the innerProperties value.
     */
    private Gen1EnvironmentResourceProperties innerProperties() {
        return this.innerProperties;
    }

    /** {@inheritDoc} */
    @Override
    public Gen1EnvironmentResource withSku(Sku sku) {
        super.withSku(sku);
        return this;
    }

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

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

    /**
     * Get the dataAccessId property: An id used to access the environment data, e.g. to query the environment's events
     * or upload reference data for the environment.
     *
     * @return the dataAccessId value.
     */
    public UUID dataAccessId() {
        return this.innerProperties() == null ? null : this.innerProperties().dataAccessId();
    }

    /**
     * Get the dataAccessFqdn property: The fully qualified domain name used to access the environment data, e.g. to
     * query the environment's events or upload reference data for the environment.
     *
     * @return the dataAccessFqdn value.
     */
    public String dataAccessFqdn() {
        return this.innerProperties() == null ? null : this.innerProperties().dataAccessFqdn();
    }

    /**
     * Get the status property: An object that represents the status of the environment, and its internal state in the
     * Time Series Insights service.
     *
     * @return the status value.
     */
    public EnvironmentStatus status() {
        return this.innerProperties() == null ? null : this.innerProperties().status();
    }

    /**
     * Get the provisioningState property: Provisioning state of the resource.
     *
     * @return the provisioningState value.
     */
    public ProvisioningState provisioningState() {
        return this.innerProperties() == null ? null : this.innerProperties().provisioningState();
    }

    /**
     * Get the creationTime property: The time the resource was created.
     *
     * @return the creationTime value.
     */
    public OffsetDateTime creationTime() {
        return this.innerProperties() == null ? null : this.innerProperties().creationTime();
    }

    /**
     * Get the dataRetentionTime property: ISO8601 timespan specifying the minimum number of days the environment's
     * events will be available for query.
     *
     * @return the dataRetentionTime value.
     */
    public Duration dataRetentionTime() {
        return this.innerProperties() == null ? null : this.innerProperties().dataRetentionTime();
    }

    /**
     * Set the dataRetentionTime property: ISO8601 timespan specifying the minimum number of days the environment's
     * events will be available for query.
     *
     * @param dataRetentionTime the dataRetentionTime value to set.
     * @return the Gen1EnvironmentResource object itself.
     */
    public Gen1EnvironmentResource withDataRetentionTime(Duration dataRetentionTime) {
        if (this.innerProperties() == null) {
            this.innerProperties = new Gen1EnvironmentResourceProperties();
        }
        this.innerProperties().withDataRetentionTime(dataRetentionTime);
        return this;
    }

    /**
     * Get the storageLimitExceededBehavior property: The behavior the Time Series Insights service should take when the
     * environment's capacity has been exceeded. If "PauseIngress" is specified, new events will not be read from the
     * event source. If "PurgeOldData" is specified, new events will continue to be read and old events will be deleted
     * from the environment. The default behavior is PurgeOldData.
     *
     * @return the storageLimitExceededBehavior value.
     */
    public StorageLimitExceededBehavior storageLimitExceededBehavior() {
        return this.innerProperties() == null ? null : this.innerProperties().storageLimitExceededBehavior();
    }

    /**
     * Set the storageLimitExceededBehavior property: The behavior the Time Series Insights service should take when the
     * environment's capacity has been exceeded. If "PauseIngress" is specified, new events will not be read from the
     * event source. If "PurgeOldData" is specified, new events will continue to be read and old events will be deleted
     * from the environment. The default behavior is PurgeOldData.
     *
     * @param storageLimitExceededBehavior the storageLimitExceededBehavior value to set.
     * @return the Gen1EnvironmentResource object itself.
     */
    public Gen1EnvironmentResource withStorageLimitExceededBehavior(
        StorageLimitExceededBehavior storageLimitExceededBehavior) {
        if (this.innerProperties() == null) {
            this.innerProperties = new Gen1EnvironmentResourceProperties();
        }
        this.innerProperties().withStorageLimitExceededBehavior(storageLimitExceededBehavior);
        return this;
    }

    /**
     * Get the partitionKeyProperties property: The list of event properties which will be used to partition data in the
     * environment. Currently, only a single partition key property is supported.
     *
     * @return the partitionKeyProperties value.
     */
    public List<TimeSeriesIdProperty> partitionKeyProperties() {
        return this.innerProperties() == null ? null : this.innerProperties().partitionKeyProperties();
    }

    /**
     * Set the partitionKeyProperties property: The list of event properties which will be used to partition data in the
     * environment. Currently, only a single partition key property is supported.
     *
     * @param partitionKeyProperties the partitionKeyProperties value to set.
     * @return the Gen1EnvironmentResource object itself.
     */
    public Gen1EnvironmentResource withPartitionKeyProperties(List<TimeSeriesIdProperty> partitionKeyProperties) {
        if (this.innerProperties() == null) {
            this.innerProperties = new Gen1EnvironmentResourceProperties();
        }
        this.innerProperties().withPartitionKeyProperties(partitionKeyProperties);
        return this;
    }

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

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