// Copyright (c) Microsoft Corporation. All rights reserved.
// Licensed under the MIT License.
// Code generated by Microsoft (R) AutoRest Code Generator.

package com.azure.resourcemanager.digitaltwins.models;

import com.azure.core.annotation.Fluent;
import com.azure.core.util.logging.ClientLogger;
import com.fasterxml.jackson.annotation.JsonProperty;
import com.fasterxml.jackson.annotation.JsonTypeInfo;
import com.fasterxml.jackson.annotation.JsonTypeName;

/** Properties of a time series database connection to Azure Data Explorer with data being sent via an EventHub. */
@JsonTypeInfo(use = JsonTypeInfo.Id.NAME, include = JsonTypeInfo.As.PROPERTY, property = "connectionType")
@JsonTypeName("AzureDataExplorer")
@Fluent
public final class AzureDataExplorerConnectionProperties extends TimeSeriesDatabaseConnectionProperties {
    /*
     * The resource ID of the Azure Data Explorer cluster.
     */
    @JsonProperty(value = "adxResourceId", required = true)
    private String adxResourceId;

    /*
     * The URI of the Azure Data Explorer endpoint.
     */
    @JsonProperty(value = "adxEndpointUri", required = true)
    private String adxEndpointUri;

    /*
     * The name of the Azure Data Explorer database.
     */
    @JsonProperty(value = "adxDatabaseName", required = true)
    private String adxDatabaseName;

    /*
     * The name of the Azure Data Explorer table used for storing updates to properties of twins and relationships.
     * Defaults to AdtPropertyEvents.
     */
    @JsonProperty(value = "adxTableName")
    private String adxTableName;

    /*
     * The name of the Azure Data Explorer table used for recording twin lifecycle events. The table will not be
     * created if this property is left unspecified.
     */
    @JsonProperty(value = "adxTwinLifecycleEventsTableName")
    private String adxTwinLifecycleEventsTableName;

    /*
     * The name of the Azure Data Explorer table used for recording relationship lifecycle events. The table will not
     * be created if this property is left unspecified.
     */
    @JsonProperty(value = "adxRelationshipLifecycleEventsTableName")
    private String adxRelationshipLifecycleEventsTableName;

    /*
     * The URL of the EventHub namespace for identity-based authentication. It must include the protocol sb://
     */
    @JsonProperty(value = "eventHubEndpointUri", required = true)
    private String eventHubEndpointUri;

    /*
     * The EventHub name in the EventHub namespace for identity-based authentication.
     */
    @JsonProperty(value = "eventHubEntityPath", required = true)
    private String eventHubEntityPath;

    /*
     * The resource ID of the EventHub namespace.
     */
    @JsonProperty(value = "eventHubNamespaceResourceId", required = true)
    private String eventHubNamespaceResourceId;

    /*
     * The EventHub consumer group to use when ADX reads from EventHub. Defaults to $Default.
     */
    @JsonProperty(value = "eventHubConsumerGroup")
    private String eventHubConsumerGroup;

    /*
     * Specifies whether or not to record twin / relationship property and item removals, including removals of indexed
     * or keyed values (such as map entries, array elements, etc.). This feature is de-activated unless explicitly set
     * to 'true'. Setting this property to 'true' will generate an additional column in the property events table in
     * ADX.
     */
    @JsonProperty(value = "recordPropertyAndItemRemovals")
    private RecordPropertyAndItemRemovals recordPropertyAndItemRemovals;

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

    /**
     * Get the adxResourceId property: The resource ID of the Azure Data Explorer cluster.
     *
     * @return the adxResourceId value.
     */
    public String adxResourceId() {
        return this.adxResourceId;
    }

    /**
     * Set the adxResourceId property: The resource ID of the Azure Data Explorer cluster.
     *
     * @param adxResourceId the adxResourceId value to set.
     * @return the AzureDataExplorerConnectionProperties object itself.
     */
    public AzureDataExplorerConnectionProperties withAdxResourceId(String adxResourceId) {
        this.adxResourceId = adxResourceId;
        return this;
    }

    /**
     * Get the adxEndpointUri property: The URI of the Azure Data Explorer endpoint.
     *
     * @return the adxEndpointUri value.
     */
    public String adxEndpointUri() {
        return this.adxEndpointUri;
    }

    /**
     * Set the adxEndpointUri property: The URI of the Azure Data Explorer endpoint.
     *
     * @param adxEndpointUri the adxEndpointUri value to set.
     * @return the AzureDataExplorerConnectionProperties object itself.
     */
    public AzureDataExplorerConnectionProperties withAdxEndpointUri(String adxEndpointUri) {
        this.adxEndpointUri = adxEndpointUri;
        return this;
    }

    /**
     * Get the adxDatabaseName property: The name of the Azure Data Explorer database.
     *
     * @return the adxDatabaseName value.
     */
    public String adxDatabaseName() {
        return this.adxDatabaseName;
    }

    /**
     * Set the adxDatabaseName property: The name of the Azure Data Explorer database.
     *
     * @param adxDatabaseName the adxDatabaseName value to set.
     * @return the AzureDataExplorerConnectionProperties object itself.
     */
    public AzureDataExplorerConnectionProperties withAdxDatabaseName(String adxDatabaseName) {
        this.adxDatabaseName = adxDatabaseName;
        return this;
    }

    /**
     * Get the adxTableName property: The name of the Azure Data Explorer table used for storing updates to properties
     * of twins and relationships. Defaults to AdtPropertyEvents.
     *
     * @return the adxTableName value.
     */
    public String adxTableName() {
        return this.adxTableName;
    }

    /**
     * Set the adxTableName property: The name of the Azure Data Explorer table used for storing updates to properties
     * of twins and relationships. Defaults to AdtPropertyEvents.
     *
     * @param adxTableName the adxTableName value to set.
     * @return the AzureDataExplorerConnectionProperties object itself.
     */
    public AzureDataExplorerConnectionProperties withAdxTableName(String adxTableName) {
        this.adxTableName = adxTableName;
        return this;
    }

    /**
     * Get the adxTwinLifecycleEventsTableName property: The name of the Azure Data Explorer table used for recording
     * twin lifecycle events. The table will not be created if this property is left unspecified.
     *
     * @return the adxTwinLifecycleEventsTableName value.
     */
    public String adxTwinLifecycleEventsTableName() {
        return this.adxTwinLifecycleEventsTableName;
    }

    /**
     * Set the adxTwinLifecycleEventsTableName property: The name of the Azure Data Explorer table used for recording
     * twin lifecycle events. The table will not be created if this property is left unspecified.
     *
     * @param adxTwinLifecycleEventsTableName the adxTwinLifecycleEventsTableName value to set.
     * @return the AzureDataExplorerConnectionProperties object itself.
     */
    public AzureDataExplorerConnectionProperties withAdxTwinLifecycleEventsTableName(
        String adxTwinLifecycleEventsTableName) {
        this.adxTwinLifecycleEventsTableName = adxTwinLifecycleEventsTableName;
        return this;
    }

    /**
     * Get the adxRelationshipLifecycleEventsTableName property: The name of the Azure Data Explorer table used for
     * recording relationship lifecycle events. The table will not be created if this property is left unspecified.
     *
     * @return the adxRelationshipLifecycleEventsTableName value.
     */
    public String adxRelationshipLifecycleEventsTableName() {
        return this.adxRelationshipLifecycleEventsTableName;
    }

    /**
     * Set the adxRelationshipLifecycleEventsTableName property: The name of the Azure Data Explorer table used for
     * recording relationship lifecycle events. The table will not be created if this property is left unspecified.
     *
     * @param adxRelationshipLifecycleEventsTableName the adxRelationshipLifecycleEventsTableName value to set.
     * @return the AzureDataExplorerConnectionProperties object itself.
     */
    public AzureDataExplorerConnectionProperties withAdxRelationshipLifecycleEventsTableName(
        String adxRelationshipLifecycleEventsTableName) {
        this.adxRelationshipLifecycleEventsTableName = adxRelationshipLifecycleEventsTableName;
        return this;
    }

    /**
     * Get the eventHubEndpointUri property: The URL of the EventHub namespace for identity-based authentication. It
     * must include the protocol sb://.
     *
     * @return the eventHubEndpointUri value.
     */
    public String eventHubEndpointUri() {
        return this.eventHubEndpointUri;
    }

    /**
     * Set the eventHubEndpointUri property: The URL of the EventHub namespace for identity-based authentication. It
     * must include the protocol sb://.
     *
     * @param eventHubEndpointUri the eventHubEndpointUri value to set.
     * @return the AzureDataExplorerConnectionProperties object itself.
     */
    public AzureDataExplorerConnectionProperties withEventHubEndpointUri(String eventHubEndpointUri) {
        this.eventHubEndpointUri = eventHubEndpointUri;
        return this;
    }

    /**
     * Get the eventHubEntityPath property: The EventHub name in the EventHub namespace for identity-based
     * authentication.
     *
     * @return the eventHubEntityPath value.
     */
    public String eventHubEntityPath() {
        return this.eventHubEntityPath;
    }

    /**
     * Set the eventHubEntityPath property: The EventHub name in the EventHub namespace for identity-based
     * authentication.
     *
     * @param eventHubEntityPath the eventHubEntityPath value to set.
     * @return the AzureDataExplorerConnectionProperties object itself.
     */
    public AzureDataExplorerConnectionProperties withEventHubEntityPath(String eventHubEntityPath) {
        this.eventHubEntityPath = eventHubEntityPath;
        return this;
    }

    /**
     * Get the eventHubNamespaceResourceId property: The resource ID of the EventHub namespace.
     *
     * @return the eventHubNamespaceResourceId value.
     */
    public String eventHubNamespaceResourceId() {
        return this.eventHubNamespaceResourceId;
    }

    /**
     * Set the eventHubNamespaceResourceId property: The resource ID of the EventHub namespace.
     *
     * @param eventHubNamespaceResourceId the eventHubNamespaceResourceId value to set.
     * @return the AzureDataExplorerConnectionProperties object itself.
     */
    public AzureDataExplorerConnectionProperties withEventHubNamespaceResourceId(String eventHubNamespaceResourceId) {
        this.eventHubNamespaceResourceId = eventHubNamespaceResourceId;
        return this;
    }

    /**
     * Get the eventHubConsumerGroup property: The EventHub consumer group to use when ADX reads from EventHub. Defaults
     * to $Default.
     *
     * @return the eventHubConsumerGroup value.
     */
    public String eventHubConsumerGroup() {
        return this.eventHubConsumerGroup;
    }

    /**
     * Set the eventHubConsumerGroup property: The EventHub consumer group to use when ADX reads from EventHub. Defaults
     * to $Default.
     *
     * @param eventHubConsumerGroup the eventHubConsumerGroup value to set.
     * @return the AzureDataExplorerConnectionProperties object itself.
     */
    public AzureDataExplorerConnectionProperties withEventHubConsumerGroup(String eventHubConsumerGroup) {
        this.eventHubConsumerGroup = eventHubConsumerGroup;
        return this;
    }

    /**
     * Get the recordPropertyAndItemRemovals property: Specifies whether or not to record twin / relationship property
     * and item removals, including removals of indexed or keyed values (such as map entries, array elements, etc.).
     * This feature is de-activated unless explicitly set to 'true'. Setting this property to 'true' will generate an
     * additional column in the property events table in ADX.
     *
     * @return the recordPropertyAndItemRemovals value.
     */
    public RecordPropertyAndItemRemovals recordPropertyAndItemRemovals() {
        return this.recordPropertyAndItemRemovals;
    }

    /**
     * Set the recordPropertyAndItemRemovals property: Specifies whether or not to record twin / relationship property
     * and item removals, including removals of indexed or keyed values (such as map entries, array elements, etc.).
     * This feature is de-activated unless explicitly set to 'true'. Setting this property to 'true' will generate an
     * additional column in the property events table in ADX.
     *
     * @param recordPropertyAndItemRemovals the recordPropertyAndItemRemovals value to set.
     * @return the AzureDataExplorerConnectionProperties object itself.
     */
    public AzureDataExplorerConnectionProperties withRecordPropertyAndItemRemovals(
        RecordPropertyAndItemRemovals recordPropertyAndItemRemovals) {
        this.recordPropertyAndItemRemovals = recordPropertyAndItemRemovals;
        return this;
    }

    /** {@inheritDoc} */
    @Override
    public AzureDataExplorerConnectionProperties withIdentity(ManagedIdentityReference identity) {
        super.withIdentity(identity);
        return this;
    }

    /**
     * Validates the instance.
     *
     * @throws IllegalArgumentException thrown if the instance is not valid.
     */
    @Override
    public void validate() {
        super.validate();
        if (adxResourceId() == null) {
            throw LOGGER
                .logExceptionAsError(
                    new IllegalArgumentException(
                        "Missing required property adxResourceId in model AzureDataExplorerConnectionProperties"));
        }
        if (adxEndpointUri() == null) {
            throw LOGGER
                .logExceptionAsError(
                    new IllegalArgumentException(
                        "Missing required property adxEndpointUri in model AzureDataExplorerConnectionProperties"));
        }
        if (adxDatabaseName() == null) {
            throw LOGGER
                .logExceptionAsError(
                    new IllegalArgumentException(
                        "Missing required property adxDatabaseName in model AzureDataExplorerConnectionProperties"));
        }
        if (eventHubEndpointUri() == null) {
            throw LOGGER
                .logExceptionAsError(
                    new IllegalArgumentException(
                        "Missing required property eventHubEndpointUri in model"
                            + " AzureDataExplorerConnectionProperties"));
        }
        if (eventHubEntityPath() == null) {
            throw LOGGER
                .logExceptionAsError(
                    new IllegalArgumentException(
                        "Missing required property eventHubEntityPath in model AzureDataExplorerConnectionProperties"));
        }
        if (eventHubNamespaceResourceId() == null) {
            throw LOGGER
                .logExceptionAsError(
                    new IllegalArgumentException(
                        "Missing required property eventHubNamespaceResourceId in model"
                            + " AzureDataExplorerConnectionProperties"));
        }
    }

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