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

package com.azure.resourcemanager.deviceprovisioningservices.models;

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

/** Description of the IoT hub. */
@Fluent
public final class IotHubDefinitionDescription {
    /*
     * flag for applying allocationPolicy or not for a given iot hub.
     */
    @JsonProperty(value = "applyAllocationPolicy")
    private Boolean applyAllocationPolicy;

    /*
     * weight to apply for a given iot h.
     */
    @JsonProperty(value = "allocationWeight")
    private Integer allocationWeight;

    /*
     * Host name of the IoT hub.
     */
    @JsonProperty(value = "name", access = JsonProperty.Access.WRITE_ONLY)
    private String name;

    /*
     * Connection string of the IoT hub.
     */
    @JsonProperty(value = "connectionString", required = true)
    private String connectionString;

    /*
     * ARM region of the IoT hub.
     */
    @JsonProperty(value = "location", required = true)
    private String location;

    /**
     * Get the applyAllocationPolicy property: flag for applying allocationPolicy or not for a given iot hub.
     *
     * @return the applyAllocationPolicy value.
     */
    public Boolean applyAllocationPolicy() {
        return this.applyAllocationPolicy;
    }

    /**
     * Set the applyAllocationPolicy property: flag for applying allocationPolicy or not for a given iot hub.
     *
     * @param applyAllocationPolicy the applyAllocationPolicy value to set.
     * @return the IotHubDefinitionDescription object itself.
     */
    public IotHubDefinitionDescription withApplyAllocationPolicy(Boolean applyAllocationPolicy) {
        this.applyAllocationPolicy = applyAllocationPolicy;
        return this;
    }

    /**
     * Get the allocationWeight property: weight to apply for a given iot h.
     *
     * @return the allocationWeight value.
     */
    public Integer allocationWeight() {
        return this.allocationWeight;
    }

    /**
     * Set the allocationWeight property: weight to apply for a given iot h.
     *
     * @param allocationWeight the allocationWeight value to set.
     * @return the IotHubDefinitionDescription object itself.
     */
    public IotHubDefinitionDescription withAllocationWeight(Integer allocationWeight) {
        this.allocationWeight = allocationWeight;
        return this;
    }

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

    /**
     * Get the connectionString property: Connection string of the IoT hub.
     *
     * @return the connectionString value.
     */
    public String connectionString() {
        return this.connectionString;
    }

    /**
     * Set the connectionString property: Connection string of the IoT hub.
     *
     * @param connectionString the connectionString value to set.
     * @return the IotHubDefinitionDescription object itself.
     */
    public IotHubDefinitionDescription withConnectionString(String connectionString) {
        this.connectionString = connectionString;
        return this;
    }

    /**
     * Get the location property: ARM region of the IoT hub.
     *
     * @return the location value.
     */
    public String location() {
        return this.location;
    }

    /**
     * Set the location property: ARM region of the IoT hub.
     *
     * @param location the location value to set.
     * @return the IotHubDefinitionDescription object itself.
     */
    public IotHubDefinitionDescription withLocation(String location) {
        this.location = location;
        return this;
    }

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

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