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

import com.azure.core.annotation.Fluent;
import com.azure.core.util.logging.ClientLogger;
import com.azure.resourcemanager.timeseriesinsights.models.EventHubEventSourceCommonProperties;
import com.azure.resourcemanager.timeseriesinsights.models.IngressStartAtType;
import com.azure.resourcemanager.timeseriesinsights.models.LocalTimestamp;
import com.fasterxml.jackson.annotation.JsonProperty;

/** Properties of the EventHub event source that are required on create or update requests. */
@Fluent
public final class EventHubEventSourceCreationProperties extends EventHubEventSourceCommonProperties {
    /*
     * The value of the shared access key that grants the Time Series Insights service read access to the event hub.
     * This property is not shown in event source responses.
     */
    @JsonProperty(value = "sharedAccessKey", required = true)
    private String sharedAccessKey;

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

    /**
     * Get the sharedAccessKey property: The value of the shared access key that grants the Time Series Insights service
     * read access to the event hub. This property is not shown in event source responses.
     *
     * @return the sharedAccessKey value.
     */
    public String sharedAccessKey() {
        return this.sharedAccessKey;
    }

    /**
     * Set the sharedAccessKey property: The value of the shared access key that grants the Time Series Insights service
     * read access to the event hub. This property is not shown in event source responses.
     *
     * @param sharedAccessKey the sharedAccessKey value to set.
     * @return the EventHubEventSourceCreationProperties object itself.
     */
    public EventHubEventSourceCreationProperties withSharedAccessKey(String sharedAccessKey) {
        this.sharedAccessKey = sharedAccessKey;
        return this;
    }

    /** {@inheritDoc} */
    @Override
    public EventHubEventSourceCreationProperties withServiceBusNamespace(String serviceBusNamespace) {
        super.withServiceBusNamespace(serviceBusNamespace);
        return this;
    }

    /** {@inheritDoc} */
    @Override
    public EventHubEventSourceCreationProperties withEventHubName(String eventHubName) {
        super.withEventHubName(eventHubName);
        return this;
    }

    /** {@inheritDoc} */
    @Override
    public EventHubEventSourceCreationProperties withConsumerGroupName(String consumerGroupName) {
        super.withConsumerGroupName(consumerGroupName);
        return this;
    }

    /** {@inheritDoc} */
    @Override
    public EventHubEventSourceCreationProperties withKeyName(String keyName) {
        super.withKeyName(keyName);
        return this;
    }

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

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

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

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

    /** {@inheritDoc} */
    @Override
    public EventHubEventSourceCreationProperties 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 (sharedAccessKey() == null) {
            throw LOGGER
                .logExceptionAsError(
                    new IllegalArgumentException(
                        "Missing required property sharedAccessKey in model EventHubEventSourceCreationProperties"));
        }
    }

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