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

package com.azure.resourcemanager.synapse.fluent.models;

import com.azure.core.annotation.Fluent;
import com.azure.core.util.logging.ClientLogger;
import com.azure.resourcemanager.synapse.models.IotHubDataFormat;
import com.azure.resourcemanager.synapse.models.ResourceProvisioningState;
import com.fasterxml.jackson.annotation.JsonProperty;
import java.util.List;

/** Class representing the Kusto Iot hub connection properties. */
@Fluent
public final class IotHubConnectionProperties {
    /*
     * The resource ID of the Iot hub to be used to create a data connection.
     */
    @JsonProperty(value = "iotHubResourceId", required = true)
    private String iotHubResourceId;

    /*
     * The iot hub consumer group.
     */
    @JsonProperty(value = "consumerGroup", required = true)
    private String consumerGroup;

    /*
     * The table where the data should be ingested. Optionally the table information can be added to each message.
     */
    @JsonProperty(value = "tableName")
    private String tableName;

    /*
     * The mapping rule to be used to ingest the data. Optionally the mapping information can be added to each message.
     */
    @JsonProperty(value = "mappingRuleName")
    private String mappingRuleName;

    /*
     * The data format of the message. Optionally the data format can be added to each message.
     */
    @JsonProperty(value = "dataFormat")
    private IotHubDataFormat dataFormat;

    /*
     * System properties of the iot hub
     */
    @JsonProperty(value = "eventSystemProperties")
    private List<String> eventSystemProperties;

    /*
     * The name of the share access policy
     */
    @JsonProperty(value = "sharedAccessPolicyName", required = true)
    private String sharedAccessPolicyName;

    /*
     * The provisioned state of the resource.
     */
    @JsonProperty(value = "provisioningState", access = JsonProperty.Access.WRITE_ONLY)
    private ResourceProvisioningState provisioningState;

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

    /**
     * Get the iotHubResourceId property: The resource ID of the Iot hub to be used to create a data connection.
     *
     * @return the iotHubResourceId value.
     */
    public String iotHubResourceId() {
        return this.iotHubResourceId;
    }

    /**
     * Set the iotHubResourceId property: The resource ID of the Iot hub to be used to create a data connection.
     *
     * @param iotHubResourceId the iotHubResourceId value to set.
     * @return the IotHubConnectionProperties object itself.
     */
    public IotHubConnectionProperties withIotHubResourceId(String iotHubResourceId) {
        this.iotHubResourceId = iotHubResourceId;
        return this;
    }

    /**
     * Get the consumerGroup property: The iot hub consumer group.
     *
     * @return the consumerGroup value.
     */
    public String consumerGroup() {
        return this.consumerGroup;
    }

    /**
     * Set the consumerGroup property: The iot hub consumer group.
     *
     * @param consumerGroup the consumerGroup value to set.
     * @return the IotHubConnectionProperties object itself.
     */
    public IotHubConnectionProperties withConsumerGroup(String consumerGroup) {
        this.consumerGroup = consumerGroup;
        return this;
    }

    /**
     * Get the tableName property: The table where the data should be ingested. Optionally the table information can be
     * added to each message.
     *
     * @return the tableName value.
     */
    public String tableName() {
        return this.tableName;
    }

    /**
     * Set the tableName property: The table where the data should be ingested. Optionally the table information can be
     * added to each message.
     *
     * @param tableName the tableName value to set.
     * @return the IotHubConnectionProperties object itself.
     */
    public IotHubConnectionProperties withTableName(String tableName) {
        this.tableName = tableName;
        return this;
    }

    /**
     * Get the mappingRuleName property: The mapping rule to be used to ingest the data. Optionally the mapping
     * information can be added to each message.
     *
     * @return the mappingRuleName value.
     */
    public String mappingRuleName() {
        return this.mappingRuleName;
    }

    /**
     * Set the mappingRuleName property: The mapping rule to be used to ingest the data. Optionally the mapping
     * information can be added to each message.
     *
     * @param mappingRuleName the mappingRuleName value to set.
     * @return the IotHubConnectionProperties object itself.
     */
    public IotHubConnectionProperties withMappingRuleName(String mappingRuleName) {
        this.mappingRuleName = mappingRuleName;
        return this;
    }

    /**
     * Get the dataFormat property: The data format of the message. Optionally the data format can be added to each
     * message.
     *
     * @return the dataFormat value.
     */
    public IotHubDataFormat dataFormat() {
        return this.dataFormat;
    }

    /**
     * Set the dataFormat property: The data format of the message. Optionally the data format can be added to each
     * message.
     *
     * @param dataFormat the dataFormat value to set.
     * @return the IotHubConnectionProperties object itself.
     */
    public IotHubConnectionProperties withDataFormat(IotHubDataFormat dataFormat) {
        this.dataFormat = dataFormat;
        return this;
    }

    /**
     * Get the eventSystemProperties property: System properties of the iot hub.
     *
     * @return the eventSystemProperties value.
     */
    public List<String> eventSystemProperties() {
        return this.eventSystemProperties;
    }

    /**
     * Set the eventSystemProperties property: System properties of the iot hub.
     *
     * @param eventSystemProperties the eventSystemProperties value to set.
     * @return the IotHubConnectionProperties object itself.
     */
    public IotHubConnectionProperties withEventSystemProperties(List<String> eventSystemProperties) {
        this.eventSystemProperties = eventSystemProperties;
        return this;
    }

    /**
     * Get the sharedAccessPolicyName property: The name of the share access policy.
     *
     * @return the sharedAccessPolicyName value.
     */
    public String sharedAccessPolicyName() {
        return this.sharedAccessPolicyName;
    }

    /**
     * Set the sharedAccessPolicyName property: The name of the share access policy.
     *
     * @param sharedAccessPolicyName the sharedAccessPolicyName value to set.
     * @return the IotHubConnectionProperties object itself.
     */
    public IotHubConnectionProperties withSharedAccessPolicyName(String sharedAccessPolicyName) {
        this.sharedAccessPolicyName = sharedAccessPolicyName;
        return this;
    }

    /**
     * Get the provisioningState property: The provisioned state of the resource.
     *
     * @return the provisioningState value.
     */
    public ResourceProvisioningState provisioningState() {
        return this.provisioningState;
    }

    /**
     * Validates the instance.
     *
     * @throws IllegalArgumentException thrown if the instance is not valid.
     */
    public void validate() {
        if (iotHubResourceId() == null) {
            throw LOGGER
                .logExceptionAsError(
                    new IllegalArgumentException(
                        "Missing required property iotHubResourceId in model IotHubConnectionProperties"));
        }
        if (consumerGroup() == null) {
            throw LOGGER
                .logExceptionAsError(
                    new IllegalArgumentException(
                        "Missing required property consumerGroup in model IotHubConnectionProperties"));
        }
        if (sharedAccessPolicyName() == null) {
            throw LOGGER
                .logExceptionAsError(
                    new IllegalArgumentException(
                        "Missing required property sharedAccessPolicyName in model IotHubConnectionProperties"));
        }
    }

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