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

package com.azure.resourcemanager.streamanalytics.models;

import com.azure.core.annotation.Fluent;
import com.azure.core.util.logging.ClientLogger;
import com.azure.resourcemanager.streamanalytics.fluent.models.IoTHubStreamInputDataSourceProperties;
import com.fasterxml.jackson.annotation.JsonIgnore;
import com.fasterxml.jackson.annotation.JsonProperty;
import com.fasterxml.jackson.annotation.JsonTypeInfo;
import com.fasterxml.jackson.annotation.JsonTypeName;

/** Describes an IoT Hub input data source that contains stream data. */
@JsonTypeInfo(use = JsonTypeInfo.Id.NAME, include = JsonTypeInfo.As.PROPERTY, property = "type")
@JsonTypeName("Microsoft.Devices/IotHubs")
@Fluent
public final class IoTHubStreamInputDataSource extends StreamInputDataSource {
    @JsonIgnore private final ClientLogger logger = new ClientLogger(IoTHubStreamInputDataSource.class);

    /*
     * The properties that are associated with an IoT Hub input containing
     * stream data. Required on PUT (CreateOrReplace) requests.
     */
    @JsonProperty(value = "properties")
    private IoTHubStreamInputDataSourceProperties innerProperties;

    /**
     * Get the innerProperties property: The properties that are associated with an IoT Hub input containing stream
     * data. Required on PUT (CreateOrReplace) requests.
     *
     * @return the innerProperties value.
     */
    private IoTHubStreamInputDataSourceProperties innerProperties() {
        return this.innerProperties;
    }

    /**
     * Get the iotHubNamespace property: The name or the URI of the IoT Hub. Required on PUT (CreateOrReplace) requests.
     *
     * @return the iotHubNamespace value.
     */
    public String iotHubNamespace() {
        return this.innerProperties() == null ? null : this.innerProperties().iotHubNamespace();
    }

    /**
     * Set the iotHubNamespace property: The name or the URI of the IoT Hub. Required on PUT (CreateOrReplace) requests.
     *
     * @param iotHubNamespace the iotHubNamespace value to set.
     * @return the IoTHubStreamInputDataSource object itself.
     */
    public IoTHubStreamInputDataSource withIotHubNamespace(String iotHubNamespace) {
        if (this.innerProperties() == null) {
            this.innerProperties = new IoTHubStreamInputDataSourceProperties();
        }
        this.innerProperties().withIotHubNamespace(iotHubNamespace);
        return this;
    }

    /**
     * Get the sharedAccessPolicyName property: The shared access policy name for the IoT Hub. This policy must contain
     * at least the Service connect permission. Required on PUT (CreateOrReplace) requests.
     *
     * @return the sharedAccessPolicyName value.
     */
    public String sharedAccessPolicyName() {
        return this.innerProperties() == null ? null : this.innerProperties().sharedAccessPolicyName();
    }

    /**
     * Set the sharedAccessPolicyName property: The shared access policy name for the IoT Hub. This policy must contain
     * at least the Service connect permission. Required on PUT (CreateOrReplace) requests.
     *
     * @param sharedAccessPolicyName the sharedAccessPolicyName value to set.
     * @return the IoTHubStreamInputDataSource object itself.
     */
    public IoTHubStreamInputDataSource withSharedAccessPolicyName(String sharedAccessPolicyName) {
        if (this.innerProperties() == null) {
            this.innerProperties = new IoTHubStreamInputDataSourceProperties();
        }
        this.innerProperties().withSharedAccessPolicyName(sharedAccessPolicyName);
        return this;
    }

    /**
     * Get the sharedAccessPolicyKey property: The shared access policy key for the specified shared access policy.
     * Required on PUT (CreateOrReplace) requests.
     *
     * @return the sharedAccessPolicyKey value.
     */
    public String sharedAccessPolicyKey() {
        return this.innerProperties() == null ? null : this.innerProperties().sharedAccessPolicyKey();
    }

    /**
     * Set the sharedAccessPolicyKey property: The shared access policy key for the specified shared access policy.
     * Required on PUT (CreateOrReplace) requests.
     *
     * @param sharedAccessPolicyKey the sharedAccessPolicyKey value to set.
     * @return the IoTHubStreamInputDataSource object itself.
     */
    public IoTHubStreamInputDataSource withSharedAccessPolicyKey(String sharedAccessPolicyKey) {
        if (this.innerProperties() == null) {
            this.innerProperties = new IoTHubStreamInputDataSourceProperties();
        }
        this.innerProperties().withSharedAccessPolicyKey(sharedAccessPolicyKey);
        return this;
    }

    /**
     * Get the consumerGroupName property: The name of an IoT Hub Consumer Group that should be used to read events from
     * the IoT Hub. If not specified, the input uses the Iot Hub’s default consumer group.
     *
     * @return the consumerGroupName value.
     */
    public String consumerGroupName() {
        return this.innerProperties() == null ? null : this.innerProperties().consumerGroupName();
    }

    /**
     * Set the consumerGroupName property: The name of an IoT Hub Consumer Group that should be used to read events from
     * the IoT Hub. If not specified, the input uses the Iot Hub’s default consumer group.
     *
     * @param consumerGroupName the consumerGroupName value to set.
     * @return the IoTHubStreamInputDataSource object itself.
     */
    public IoTHubStreamInputDataSource withConsumerGroupName(String consumerGroupName) {
        if (this.innerProperties() == null) {
            this.innerProperties = new IoTHubStreamInputDataSourceProperties();
        }
        this.innerProperties().withConsumerGroupName(consumerGroupName);
        return this;
    }

    /**
     * Get the endpoint property: The IoT Hub endpoint to connect to (ie. messages/events,
     * messages/operationsMonitoringEvents, etc.).
     *
     * @return the endpoint value.
     */
    public String endpoint() {
        return this.innerProperties() == null ? null : this.innerProperties().endpoint();
    }

    /**
     * Set the endpoint property: The IoT Hub endpoint to connect to (ie. messages/events,
     * messages/operationsMonitoringEvents, etc.).
     *
     * @param endpoint the endpoint value to set.
     * @return the IoTHubStreamInputDataSource object itself.
     */
    public IoTHubStreamInputDataSource withEndpoint(String endpoint) {
        if (this.innerProperties() == null) {
            this.innerProperties = new IoTHubStreamInputDataSourceProperties();
        }
        this.innerProperties().withEndpoint(endpoint);
        return this;
    }

    /**
     * Validates the instance.
     *
     * @throws IllegalArgumentException thrown if the instance is not valid.
     */
    @Override
    public void validate() {
        super.validate();
        if (innerProperties() != null) {
            innerProperties().validate();
        }
    }
}
