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

/** An event source that receives its data from an Azure EventHub. */
@JsonTypeInfo(use = JsonTypeInfo.Id.NAME, include = JsonTypeInfo.As.PROPERTY, property = "kind")
@JsonTypeName("Microsoft.EventHub")
@Fluent
public final class EventHubEventSourceResource extends EventSourceResourceInner {
    /*
     * Properties of the EventHub event source resource.
     */
    @JsonProperty(value = "properties", required = true)
    private EventHubEventSourceResourceProperties innerProperties = new EventHubEventSourceResourceProperties();

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

    /**
     * Get the innerProperties property: Properties of the EventHub event source resource.
     *
     * @return the innerProperties value.
     */
    private EventHubEventSourceResourceProperties innerProperties() {
        return this.innerProperties;
    }

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

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

    /**
     * Get the serviceBusNamespace property: The name of the service bus that contains the event hub.
     *
     * @return the serviceBusNamespace value.
     */
    public String serviceBusNamespace() {
        return this.innerProperties() == null ? null : this.innerProperties().serviceBusNamespace();
    }

    /**
     * Set the serviceBusNamespace property: The name of the service bus that contains the event hub.
     *
     * @param serviceBusNamespace the serviceBusNamespace value to set.
     * @return the EventHubEventSourceResource object itself.
     */
    public EventHubEventSourceResource withServiceBusNamespace(String serviceBusNamespace) {
        if (this.innerProperties() == null) {
            this.innerProperties = new EventHubEventSourceResourceProperties();
        }
        this.innerProperties().withServiceBusNamespace(serviceBusNamespace);
        return this;
    }

    /**
     * Get the eventHubName property: The name of the event hub.
     *
     * @return the eventHubName value.
     */
    public String eventHubName() {
        return this.innerProperties() == null ? null : this.innerProperties().eventHubName();
    }

    /**
     * Set the eventHubName property: The name of the event hub.
     *
     * @param eventHubName the eventHubName value to set.
     * @return the EventHubEventSourceResource object itself.
     */
    public EventHubEventSourceResource withEventHubName(String eventHubName) {
        if (this.innerProperties() == null) {
            this.innerProperties = new EventHubEventSourceResourceProperties();
        }
        this.innerProperties().withEventHubName(eventHubName);
        return this;
    }

    /**
     * Get the consumerGroupName property: The name of the event hub's consumer group that holds the partitions from
     * which events will be read.
     *
     * @return the consumerGroupName value.
     */
    public String consumerGroupName() {
        return this.innerProperties() == null ? null : this.innerProperties().consumerGroupName();
    }

    /**
     * Set the consumerGroupName property: The name of the event hub's consumer group that holds the partitions from
     * which events will be read.
     *
     * @param consumerGroupName the consumerGroupName value to set.
     * @return the EventHubEventSourceResource object itself.
     */
    public EventHubEventSourceResource withConsumerGroupName(String consumerGroupName) {
        if (this.innerProperties() == null) {
            this.innerProperties = new EventHubEventSourceResourceProperties();
        }
        this.innerProperties().withConsumerGroupName(consumerGroupName);
        return this;
    }

    /**
     * Get the keyName property: The name of the SAS key that grants the Time Series Insights service access to the
     * event hub. The shared access policies for this key must grant 'Listen' permissions to the event hub.
     *
     * @return the keyName value.
     */
    public String keyName() {
        return this.innerProperties() == null ? null : this.innerProperties().keyName();
    }

    /**
     * Set the keyName property: The name of the SAS key that grants the Time Series Insights service access to the
     * event hub. The shared access policies for this key must grant 'Listen' permissions to the event hub.
     *
     * @param keyName the keyName value to set.
     * @return the EventHubEventSourceResource object itself.
     */
    public EventHubEventSourceResource withKeyName(String keyName) {
        if (this.innerProperties() == null) {
            this.innerProperties = new EventHubEventSourceResourceProperties();
        }
        this.innerProperties().withKeyName(keyName);
        return this;
    }

    /**
     * Get the eventSourceResourceId property: The resource id of the event source in Azure Resource Manager.
     *
     * @return the eventSourceResourceId value.
     */
    public String eventSourceResourceId() {
        return this.innerProperties() == null ? null : this.innerProperties().eventSourceResourceId();
    }

    /**
     * Set the eventSourceResourceId property: The resource id of the event source in Azure Resource Manager.
     *
     * @param eventSourceResourceId the eventSourceResourceId value to set.
     * @return the EventHubEventSourceResource object itself.
     */
    public EventHubEventSourceResource withEventSourceResourceId(String eventSourceResourceId) {
        if (this.innerProperties() == null) {
            this.innerProperties = new EventHubEventSourceResourceProperties();
        }
        this.innerProperties().withEventSourceResourceId(eventSourceResourceId);
        return this;
    }

    /**
     * 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.innerProperties() == null ? null : this.innerProperties().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 EventHubEventSourceResource object itself.
     */
    public EventHubEventSourceResource withTimestampPropertyName(String timestampPropertyName) {
        if (this.innerProperties() == null) {
            this.innerProperties = new EventHubEventSourceResourceProperties();
        }
        this.innerProperties().withTimestampPropertyName(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.innerProperties() == null ? null : this.innerProperties().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 EventHubEventSourceResource object itself.
     */
    public EventHubEventSourceResource withLocalTimestamp(LocalTimestamp localTimestamp) {
        if (this.innerProperties() == null) {
            this.innerProperties = new EventHubEventSourceResourceProperties();
        }
        this.innerProperties().withLocalTimestamp(localTimestamp);
        return this;
    }

    /**
     * Get the type property: The type of the ingressStartAt, It can be "EarliestAvailable", "EventSourceCreationTime",
     * "CustomEnqueuedTime".
     *
     * @return the type value.
     */
    public IngressStartAtType typePropertiesType() {
        return this.innerProperties() == null ? null : this.innerProperties().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 EventHubEventSourceResource object itself.
     */
    public EventHubEventSourceResource withTypePropertiesType(IngressStartAtType type) {
        if (this.innerProperties() == null) {
            this.innerProperties = new EventHubEventSourceResourceProperties();
        }
        this.innerProperties().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.innerProperties() == null ? null : this.innerProperties().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 EventHubEventSourceResource object itself.
     */
    public EventHubEventSourceResource withTime(String time) {
        if (this.innerProperties() == null) {
            this.innerProperties = new EventHubEventSourceResourceProperties();
        }
        this.innerProperties().withTime(time);
        return this;
    }

    /**
     * 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();
    }

    /**
     * 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 EventHubEventSourceResource"));
        } else {
            innerProperties().validate();
        }
    }

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