// 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.resourcemanager.timeseriesinsights.fluent.models.IngressStartAtProperties;
import com.fasterxml.jackson.annotation.JsonProperty;

/** Properties of the event source. */
@Fluent
public class EventSourceCommonProperties extends ResourceProperties {
    /*
     * The event property that will be used as the event source's timestamp. If a value isn't specified for
     * timestampPropertyName, or if null or empty-string is specified, the event creation time will be used.
     */
    @JsonProperty(value = "timestampPropertyName")
    private String timestampPropertyName;

    /*
     * An object that represents the local timestamp property. It contains the format of local timestamp that needs to
     * be used and the corresponding timezone offset information. If a value isn't specified for localTimestamp, or if
     * null, then the local timestamp will not be ingressed with the events.
     */
    @JsonProperty(value = "localTimestamp")
    private LocalTimestamp localTimestamp;

    /*
     * An object that contains the details about the starting point in time to ingest events.
     */
    @JsonProperty(value = "ingressStartAt")
    private IngressStartAtProperties innerIngressStartAt;

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

    /**
     * Get the timestampPropertyName property: The event property that will be used as the event source's timestamp. If
     * a value isn't specified for timestampPropertyName, or if null or empty-string is specified, the event creation
     * time will be used.
     *
     * @return the timestampPropertyName value.
     */
    public String timestampPropertyName() {
        return this.timestampPropertyName;
    }

    /**
     * Set the timestampPropertyName property: The event property that will be used as the event source's timestamp. If
     * a value isn't specified for timestampPropertyName, or if null or empty-string is specified, the event creation
     * time will be used.
     *
     * @param timestampPropertyName the timestampPropertyName value to set.
     * @return the EventSourceCommonProperties object itself.
     */
    public EventSourceCommonProperties withTimestampPropertyName(String timestampPropertyName) {
        this.timestampPropertyName = timestampPropertyName;
        return this;
    }

    /**
     * Get the localTimestamp property: An object that represents the local timestamp property. It contains the format
     * of local timestamp that needs to be used and the corresponding timezone offset information. If a value isn't
     * specified for localTimestamp, or if null, then the local timestamp will not be ingressed with the events.
     *
     * @return the localTimestamp value.
     */
    public LocalTimestamp localTimestamp() {
        return this.localTimestamp;
    }

    /**
     * Set the localTimestamp property: An object that represents the local timestamp property. It contains the format
     * of local timestamp that needs to be used and the corresponding timezone offset information. If a value isn't
     * specified for localTimestamp, or if null, then the local timestamp will not be ingressed with the events.
     *
     * @param localTimestamp the localTimestamp value to set.
     * @return the EventSourceCommonProperties object itself.
     */
    public EventSourceCommonProperties withLocalTimestamp(LocalTimestamp localTimestamp) {
        this.localTimestamp = localTimestamp;
        return this;
    }

    /**
     * Get the innerIngressStartAt property: An object that contains the details about the starting point in time to
     * ingest events.
     *
     * @return the innerIngressStartAt value.
     */
    private IngressStartAtProperties innerIngressStartAt() {
        return this.innerIngressStartAt;
    }

    /**
     * Get the type property: The type of the ingressStartAt, It can be "EarliestAvailable", "EventSourceCreationTime",
     * "CustomEnqueuedTime".
     *
     * @return the type value.
     */
    public IngressStartAtType type() {
        return this.innerIngressStartAt() == null ? null : this.innerIngressStartAt().type();
    }

    /**
     * Set the type property: The type of the ingressStartAt, It can be "EarliestAvailable", "EventSourceCreationTime",
     * "CustomEnqueuedTime".
     *
     * @param type the type value to set.
     * @return the EventSourceCommonProperties object itself.
     */
    public EventSourceCommonProperties withType(IngressStartAtType type) {
        if (this.innerIngressStartAt() == null) {
            this.innerIngressStartAt = new IngressStartAtProperties();
        }
        this.innerIngressStartAt().withType(type);
        return this;
    }

    /**
     * Get the time property: ISO8601 UTC datetime with seconds precision (milliseconds are optional), specifying the
     * date and time that will be the starting point for Events to be consumed.
     *
     * @return the time value.
     */
    public String time() {
        return this.innerIngressStartAt() == null ? null : this.innerIngressStartAt().time();
    }

    /**
     * Set the time property: ISO8601 UTC datetime with seconds precision (milliseconds are optional), specifying the
     * date and time that will be the starting point for Events to be consumed.
     *
     * @param time the time value to set.
     * @return the EventSourceCommonProperties object itself.
     */
    public EventSourceCommonProperties withTime(String time) {
        if (this.innerIngressStartAt() == null) {
            this.innerIngressStartAt = new IngressStartAtProperties();
        }
        this.innerIngressStartAt().withTime(time);
        return this;
    }

    /**
     * Validates the instance.
     *
     * @throws IllegalArgumentException thrown if the instance is not valid.
     */
    @Override
    public void validate() {
        super.validate();
        if (localTimestamp() != null) {
            localTimestamp().validate();
        }
        if (innerIngressStartAt() != null) {
            innerIngressStartAt().validate();
        }
    }
}
