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

package com.azure.resourcemanager.hdinsight.models;

import com.azure.core.annotation.Fluent;
import com.azure.core.util.logging.ClientLogger;
import com.azure.resourcemanager.hdinsight.fluent.models.PrivateLinkConfigurationProperties;
import com.fasterxml.jackson.annotation.JsonProperty;
import java.util.List;

/** The private link configuration. */
@Fluent
public final class PrivateLinkConfiguration {
    /*
     * The private link configuration id.
     */
    @JsonProperty(value = "id", access = JsonProperty.Access.WRITE_ONLY)
    private String id;

    /*
     * The name of private link configuration.
     */
    @JsonProperty(value = "name", required = true)
    private String name;

    /*
     * The type of the private link configuration.
     */
    @JsonProperty(value = "type", access = JsonProperty.Access.WRITE_ONLY)
    private String type;

    /*
     * The private link configuration properties.
     */
    @JsonProperty(value = "properties", required = true)
    private PrivateLinkConfigurationProperties innerProperties = new PrivateLinkConfigurationProperties();

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

    /**
     * Get the id property: The private link configuration id.
     *
     * @return the id value.
     */
    public String id() {
        return this.id;
    }

    /**
     * Get the name property: The name of private link configuration.
     *
     * @return the name value.
     */
    public String name() {
        return this.name;
    }

    /**
     * Set the name property: The name of private link configuration.
     *
     * @param name the name value to set.
     * @return the PrivateLinkConfiguration object itself.
     */
    public PrivateLinkConfiguration withName(String name) {
        this.name = name;
        return this;
    }

    /**
     * Get the type property: The type of the private link configuration.
     *
     * @return the type value.
     */
    public String type() {
        return this.type;
    }

    /**
     * Get the innerProperties property: The private link configuration properties.
     *
     * @return the innerProperties value.
     */
    private PrivateLinkConfigurationProperties innerProperties() {
        return this.innerProperties;
    }

    /**
     * Get the groupId property: The HDInsight private linkable sub-resource name to apply the private link
     * configuration to. For example, 'headnode', 'gateway', 'edgenode'.
     *
     * @return the groupId value.
     */
    public String groupId() {
        return this.innerProperties() == null ? null : this.innerProperties().groupId();
    }

    /**
     * Set the groupId property: The HDInsight private linkable sub-resource name to apply the private link
     * configuration to. For example, 'headnode', 'gateway', 'edgenode'.
     *
     * @param groupId the groupId value to set.
     * @return the PrivateLinkConfiguration object itself.
     */
    public PrivateLinkConfiguration withGroupId(String groupId) {
        if (this.innerProperties() == null) {
            this.innerProperties = new PrivateLinkConfigurationProperties();
        }
        this.innerProperties().withGroupId(groupId);
        return this;
    }

    /**
     * Get the provisioningState property: The private link configuration provisioning state, which only appears in the
     * response.
     *
     * @return the provisioningState value.
     */
    public PrivateLinkConfigurationProvisioningState provisioningState() {
        return this.innerProperties() == null ? null : this.innerProperties().provisioningState();
    }

    /**
     * Get the ipConfigurations property: The IP configurations for the private link service.
     *
     * @return the ipConfigurations value.
     */
    public List<IpConfiguration> ipConfigurations() {
        return this.innerProperties() == null ? null : this.innerProperties().ipConfigurations();
    }

    /**
     * Set the ipConfigurations property: The IP configurations for the private link service.
     *
     * @param ipConfigurations the ipConfigurations value to set.
     * @return the PrivateLinkConfiguration object itself.
     */
    public PrivateLinkConfiguration withIpConfigurations(List<IpConfiguration> ipConfigurations) {
        if (this.innerProperties() == null) {
            this.innerProperties = new PrivateLinkConfigurationProperties();
        }
        this.innerProperties().withIpConfigurations(ipConfigurations);
        return this;
    }

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

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