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

package com.azure.resourcemanager.security.models;

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

/** Settings for hybrid compute management. */
@Fluent
public final class HybridComputeSettingsProperties {
    /*
     * State of the service principal and its secret
     */
    @JsonProperty(value = "hybridComputeProvisioningState", access = JsonProperty.Access.WRITE_ONLY)
    private HybridComputeProvisioningState hybridComputeProvisioningState;

    /*
     * Whether or not to automatically install Azure Arc (hybrid compute) agents on machines
     */
    @JsonProperty(value = "autoProvision", required = true)
    private AutoProvision autoProvision;

    /*
     * The name of the resource group where Arc (Hybrid Compute) connectors are connected.
     */
    @JsonProperty(value = "resourceGroupName")
    private String resourceGroupName;

    /*
     * The location where the metadata of machines will be stored
     */
    @JsonProperty(value = "region")
    private String region;

    /*
     * For a non-Azure machine that is not connected directly to the internet, specify a proxy server that the
     * non-Azure machine can use.
     */
    @JsonProperty(value = "proxyServer")
    private ProxyServerProperties proxyServer;

    /*
     * An object to access resources that are secured by an Azure AD tenant.
     */
    @JsonProperty(value = "servicePrincipal")
    private ServicePrincipalProperties servicePrincipal;

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

    /**
     * Get the hybridComputeProvisioningState property: State of the service principal and its secret.
     *
     * @return the hybridComputeProvisioningState value.
     */
    public HybridComputeProvisioningState hybridComputeProvisioningState() {
        return this.hybridComputeProvisioningState;
    }

    /**
     * Get the autoProvision property: Whether or not to automatically install Azure Arc (hybrid compute) agents on
     * machines.
     *
     * @return the autoProvision value.
     */
    public AutoProvision autoProvision() {
        return this.autoProvision;
    }

    /**
     * Set the autoProvision property: Whether or not to automatically install Azure Arc (hybrid compute) agents on
     * machines.
     *
     * @param autoProvision the autoProvision value to set.
     * @return the HybridComputeSettingsProperties object itself.
     */
    public HybridComputeSettingsProperties withAutoProvision(AutoProvision autoProvision) {
        this.autoProvision = autoProvision;
        return this;
    }

    /**
     * Get the resourceGroupName property: The name of the resource group where Arc (Hybrid Compute) connectors are
     * connected.
     *
     * @return the resourceGroupName value.
     */
    public String resourceGroupName() {
        return this.resourceGroupName;
    }

    /**
     * Set the resourceGroupName property: The name of the resource group where Arc (Hybrid Compute) connectors are
     * connected.
     *
     * @param resourceGroupName the resourceGroupName value to set.
     * @return the HybridComputeSettingsProperties object itself.
     */
    public HybridComputeSettingsProperties withResourceGroupName(String resourceGroupName) {
        this.resourceGroupName = resourceGroupName;
        return this;
    }

    /**
     * Get the region property: The location where the metadata of machines will be stored.
     *
     * @return the region value.
     */
    public String region() {
        return this.region;
    }

    /**
     * Set the region property: The location where the metadata of machines will be stored.
     *
     * @param region the region value to set.
     * @return the HybridComputeSettingsProperties object itself.
     */
    public HybridComputeSettingsProperties withRegion(String region) {
        this.region = region;
        return this;
    }

    /**
     * Get the proxyServer property: For a non-Azure machine that is not connected directly to the internet, specify a
     * proxy server that the non-Azure machine can use.
     *
     * @return the proxyServer value.
     */
    public ProxyServerProperties proxyServer() {
        return this.proxyServer;
    }

    /**
     * Set the proxyServer property: For a non-Azure machine that is not connected directly to the internet, specify a
     * proxy server that the non-Azure machine can use.
     *
     * @param proxyServer the proxyServer value to set.
     * @return the HybridComputeSettingsProperties object itself.
     */
    public HybridComputeSettingsProperties withProxyServer(ProxyServerProperties proxyServer) {
        this.proxyServer = proxyServer;
        return this;
    }

    /**
     * Get the servicePrincipal property: An object to access resources that are secured by an Azure AD tenant.
     *
     * @return the servicePrincipal value.
     */
    public ServicePrincipalProperties servicePrincipal() {
        return this.servicePrincipal;
    }

    /**
     * Set the servicePrincipal property: An object to access resources that are secured by an Azure AD tenant.
     *
     * @param servicePrincipal the servicePrincipal value to set.
     * @return the HybridComputeSettingsProperties object itself.
     */
    public HybridComputeSettingsProperties withServicePrincipal(ServicePrincipalProperties servicePrincipal) {
        this.servicePrincipal = servicePrincipal;
        return this;
    }

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

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