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

/** Properties of the EventHub event source. */
@Fluent
public class EventHubEventSourceCommonProperties extends AzureEventSourceProperties {
    /*
     * The name of the service bus that contains the event hub.
     */
    @JsonProperty(value = "serviceBusNamespace", required = true)
    private String serviceBusNamespace;

    /*
     * The name of the event hub.
     */
    @JsonProperty(value = "eventHubName", required = true)
    private String eventHubName;

    /*
     * The name of the event hub's consumer group that holds the partitions from which events will be read.
     */
    @JsonProperty(value = "consumerGroupName", required = true)
    private String consumerGroupName;

    /*
     * 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.
     */
    @JsonProperty(value = "keyName", required = true)
    private String keyName;

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

    /**
     * Get the serviceBusNamespace property: The name of the service bus that contains the event hub.
     *
     * @return the serviceBusNamespace value.
     */
    public String serviceBusNamespace() {
        return this.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 EventHubEventSourceCommonProperties object itself.
     */
    public EventHubEventSourceCommonProperties withServiceBusNamespace(String serviceBusNamespace) {
        this.serviceBusNamespace = serviceBusNamespace;
        return this;
    }

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

    /**
     * Set the eventHubName property: The name of the event hub.
     *
     * @param eventHubName the eventHubName value to set.
     * @return the EventHubEventSourceCommonProperties object itself.
     */
    public EventHubEventSourceCommonProperties withEventHubName(String eventHubName) {
        this.eventHubName = 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.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 EventHubEventSourceCommonProperties object itself.
     */
    public EventHubEventSourceCommonProperties withConsumerGroupName(String consumerGroupName) {
        this.consumerGroupName = 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.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 EventHubEventSourceCommonProperties object itself.
     */
    public EventHubEventSourceCommonProperties withKeyName(String keyName) {
        this.keyName = keyName;
        return this;
    }

    /** {@inheritDoc} */
    @Override
    public EventHubEventSourceCommonProperties withEventSourceResourceId(String eventSourceResourceId) {
        super.withEventSourceResourceId(eventSourceResourceId);
        return this;
    }

    /** {@inheritDoc} */
    @Override
    public EventHubEventSourceCommonProperties withTimestampPropertyName(String timestampPropertyName) {
        super.withTimestampPropertyName(timestampPropertyName);
        return this;
    }

    /** {@inheritDoc} */
    @Override
    public EventHubEventSourceCommonProperties withLocalTimestamp(LocalTimestamp localTimestamp) {
        super.withLocalTimestamp(localTimestamp);
        return this;
    }

    /** {@inheritDoc} */
    @Override
    public EventHubEventSourceCommonProperties withType(IngressStartAtType type) {
        super.withType(type);
        return this;
    }

    /** {@inheritDoc} */
    @Override
    public EventHubEventSourceCommonProperties withTime(String time) {
        super.withTime(time);
        return this;
    }

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

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