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

package com.azure.resourcemanager.labservices.models;

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

/** The base virtual machine configuration for a lab. */
@Fluent
public final class VirtualMachineProfile {
    /*
     * Indicates what lab virtual machines are created from.
     */
    @JsonProperty(value = "createOption", required = true)
    private CreateOption createOption;

    /*
     * The image configuration for lab virtual machines.
     */
    @JsonProperty(value = "imageReference", required = true)
    private ImageReference imageReference;

    /*
     * The OS type of the image
     */
    @JsonProperty(value = "osType", access = JsonProperty.Access.WRITE_ONLY)
    private OsType osType;

    /*
     * The SKU for the lab. Defines the type of virtual machines used in the lab.
     */
    @JsonProperty(value = "sku", required = true)
    private Sku sku;

    /*
     * Additional VM capabilities.
     */
    @JsonProperty(value = "additionalCapabilities")
    private VirtualMachineAdditionalCapabilities additionalCapabilities;

    /*
     * The initial quota alloted to each lab user. Must be a time span between 0 and 9999 hours.
     */
    @JsonProperty(value = "usageQuota", required = true)
    private Duration usageQuota;

    /*
     * Enabling this option will use the same password for all user VMs.
     */
    @JsonProperty(value = "useSharedPassword")
    private EnableState useSharedPassword;

    /*
     * Credentials for the admin user on the VM.
     */
    @JsonProperty(value = "adminUser", required = true)
    private Credentials adminUser;

    /*
     * Credentials for the non-admin user on the VM, if one exists.
     */
    @JsonProperty(value = "nonAdminUser")
    private Credentials nonAdminUser;

    /**
     * Get the createOption property: Indicates what lab virtual machines are created from.
     *
     * @return the createOption value.
     */
    public CreateOption createOption() {
        return this.createOption;
    }

    /**
     * Set the createOption property: Indicates what lab virtual machines are created from.
     *
     * @param createOption the createOption value to set.
     * @return the VirtualMachineProfile object itself.
     */
    public VirtualMachineProfile withCreateOption(CreateOption createOption) {
        this.createOption = createOption;
        return this;
    }

    /**
     * Get the imageReference property: The image configuration for lab virtual machines.
     *
     * @return the imageReference value.
     */
    public ImageReference imageReference() {
        return this.imageReference;
    }

    /**
     * Set the imageReference property: The image configuration for lab virtual machines.
     *
     * @param imageReference the imageReference value to set.
     * @return the VirtualMachineProfile object itself.
     */
    public VirtualMachineProfile withImageReference(ImageReference imageReference) {
        this.imageReference = imageReference;
        return this;
    }

    /**
     * Get the osType property: The OS type of the image.
     *
     * @return the osType value.
     */
    public OsType osType() {
        return this.osType;
    }

    /**
     * Get the sku property: The SKU for the lab. Defines the type of virtual machines used in the lab.
     *
     * @return the sku value.
     */
    public Sku sku() {
        return this.sku;
    }

    /**
     * Set the sku property: The SKU for the lab. Defines the type of virtual machines used in the lab.
     *
     * @param sku the sku value to set.
     * @return the VirtualMachineProfile object itself.
     */
    public VirtualMachineProfile withSku(Sku sku) {
        this.sku = sku;
        return this;
    }

    /**
     * Get the additionalCapabilities property: Additional VM capabilities.
     *
     * @return the additionalCapabilities value.
     */
    public VirtualMachineAdditionalCapabilities additionalCapabilities() {
        return this.additionalCapabilities;
    }

    /**
     * Set the additionalCapabilities property: Additional VM capabilities.
     *
     * @param additionalCapabilities the additionalCapabilities value to set.
     * @return the VirtualMachineProfile object itself.
     */
    public VirtualMachineProfile withAdditionalCapabilities(
        VirtualMachineAdditionalCapabilities additionalCapabilities) {
        this.additionalCapabilities = additionalCapabilities;
        return this;
    }

    /**
     * Get the usageQuota property: The initial quota alloted to each lab user. Must be a time span between 0 and 9999
     * hours.
     *
     * @return the usageQuota value.
     */
    public Duration usageQuota() {
        return this.usageQuota;
    }

    /**
     * Set the usageQuota property: The initial quota alloted to each lab user. Must be a time span between 0 and 9999
     * hours.
     *
     * @param usageQuota the usageQuota value to set.
     * @return the VirtualMachineProfile object itself.
     */
    public VirtualMachineProfile withUsageQuota(Duration usageQuota) {
        this.usageQuota = usageQuota;
        return this;
    }

    /**
     * Get the useSharedPassword property: Enabling this option will use the same password for all user VMs.
     *
     * @return the useSharedPassword value.
     */
    public EnableState useSharedPassword() {
        return this.useSharedPassword;
    }

    /**
     * Set the useSharedPassword property: Enabling this option will use the same password for all user VMs.
     *
     * @param useSharedPassword the useSharedPassword value to set.
     * @return the VirtualMachineProfile object itself.
     */
    public VirtualMachineProfile withUseSharedPassword(EnableState useSharedPassword) {
        this.useSharedPassword = useSharedPassword;
        return this;
    }

    /**
     * Get the adminUser property: Credentials for the admin user on the VM.
     *
     * @return the adminUser value.
     */
    public Credentials adminUser() {
        return this.adminUser;
    }

    /**
     * Set the adminUser property: Credentials for the admin user on the VM.
     *
     * @param adminUser the adminUser value to set.
     * @return the VirtualMachineProfile object itself.
     */
    public VirtualMachineProfile withAdminUser(Credentials adminUser) {
        this.adminUser = adminUser;
        return this;
    }

    /**
     * Get the nonAdminUser property: Credentials for the non-admin user on the VM, if one exists.
     *
     * @return the nonAdminUser value.
     */
    public Credentials nonAdminUser() {
        return this.nonAdminUser;
    }

    /**
     * Set the nonAdminUser property: Credentials for the non-admin user on the VM, if one exists.
     *
     * @param nonAdminUser the nonAdminUser value to set.
     * @return the VirtualMachineProfile object itself.
     */
    public VirtualMachineProfile withNonAdminUser(Credentials nonAdminUser) {
        this.nonAdminUser = nonAdminUser;
        return this;
    }

    /**
     * Validates the instance.
     *
     * @throws IllegalArgumentException thrown if the instance is not valid.
     */
    public void validate() {
        if (createOption() == null) {
            throw LOGGER
                .logExceptionAsError(
                    new IllegalArgumentException(
                        "Missing required property createOption in model VirtualMachineProfile"));
        }
        if (imageReference() == null) {
            throw LOGGER
                .logExceptionAsError(
                    new IllegalArgumentException(
                        "Missing required property imageReference in model VirtualMachineProfile"));
        } else {
            imageReference().validate();
        }
        if (sku() == null) {
            throw LOGGER
                .logExceptionAsError(
                    new IllegalArgumentException("Missing required property sku in model VirtualMachineProfile"));
        } else {
            sku().validate();
        }
        if (additionalCapabilities() != null) {
            additionalCapabilities().validate();
        }
        if (usageQuota() == null) {
            throw LOGGER
                .logExceptionAsError(
                    new IllegalArgumentException(
                        "Missing required property usageQuota in model VirtualMachineProfile"));
        }
        if (adminUser() == null) {
            throw LOGGER
                .logExceptionAsError(
                    new IllegalArgumentException("Missing required property adminUser in model VirtualMachineProfile"));
        } else {
            adminUser().validate();
        }
        if (nonAdminUser() != null) {
            nonAdminUser().validate();
        }
    }

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