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

package com.azure.resourcemanager.workloads.fluent.models;

import com.azure.core.annotation.Fluent;
import com.azure.core.util.logging.ClientLogger;
import com.azure.resourcemanager.workloads.models.ManagedRGConfiguration;
import com.azure.resourcemanager.workloads.models.SapConfiguration;
import com.azure.resourcemanager.workloads.models.SapEnvironmentType;
import com.azure.resourcemanager.workloads.models.SapHealthState;
import com.azure.resourcemanager.workloads.models.SapProductType;
import com.azure.resourcemanager.workloads.models.SapVirtualInstanceError;
import com.azure.resourcemanager.workloads.models.SapVirtualInstanceProvisioningState;
import com.azure.resourcemanager.workloads.models.SapVirtualInstanceState;
import com.azure.resourcemanager.workloads.models.SapVirtualInstanceStatus;
import com.fasterxml.jackson.annotation.JsonProperty;

/** Defines the Virtual Instance for SAP solutions resource properties. */
@Fluent
public final class SapVirtualInstanceProperties {
    /*
     * Defines the environment type - Production/Non Production.
     */
    @JsonProperty(value = "environment", required = true)
    private SapEnvironmentType environment;

    /*
     * Defines the SAP Product type.
     */
    @JsonProperty(value = "sapProduct", required = true)
    private SapProductType sapProduct;

    /*
     * Defines if the SAP system is being created using Azure Center for SAP solutions (ACSS) or if an existing SAP
     * system is being registered with ACSS
     */
    @JsonProperty(value = "configuration", required = true)
    private SapConfiguration configuration;

    /*
     * Managed resource group configuration
     */
    @JsonProperty(value = "managedResourceGroupConfiguration")
    private ManagedRGConfiguration managedResourceGroupConfiguration;

    /*
     * Defines the SAP Instance status.
     */
    @JsonProperty(value = "status", access = JsonProperty.Access.WRITE_ONLY)
    private SapVirtualInstanceStatus status;

    /*
     * Defines the health of SAP Instances.
     */
    @JsonProperty(value = "health", access = JsonProperty.Access.WRITE_ONLY)
    private SapHealthState health;

    /*
     * Defines the Virtual Instance for SAP state.
     */
    @JsonProperty(value = "state", access = JsonProperty.Access.WRITE_ONLY)
    private SapVirtualInstanceState state;

    /*
     * Defines the provisioning states.
     */
    @JsonProperty(value = "provisioningState", access = JsonProperty.Access.WRITE_ONLY)
    private SapVirtualInstanceProvisioningState provisioningState;

    /*
     * Indicates any errors on the Virtual Instance for SAP solutions resource.
     */
    @JsonProperty(value = "errors", access = JsonProperty.Access.WRITE_ONLY)
    private SapVirtualInstanceError errors;

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

    /**
     * Get the environment property: Defines the environment type - Production/Non Production.
     *
     * @return the environment value.
     */
    public SapEnvironmentType environment() {
        return this.environment;
    }

    /**
     * Set the environment property: Defines the environment type - Production/Non Production.
     *
     * @param environment the environment value to set.
     * @return the SapVirtualInstanceProperties object itself.
     */
    public SapVirtualInstanceProperties withEnvironment(SapEnvironmentType environment) {
        this.environment = environment;
        return this;
    }

    /**
     * Get the sapProduct property: Defines the SAP Product type.
     *
     * @return the sapProduct value.
     */
    public SapProductType sapProduct() {
        return this.sapProduct;
    }

    /**
     * Set the sapProduct property: Defines the SAP Product type.
     *
     * @param sapProduct the sapProduct value to set.
     * @return the SapVirtualInstanceProperties object itself.
     */
    public SapVirtualInstanceProperties withSapProduct(SapProductType sapProduct) {
        this.sapProduct = sapProduct;
        return this;
    }

    /**
     * Get the configuration property: Defines if the SAP system is being created using Azure Center for SAP solutions
     * (ACSS) or if an existing SAP system is being registered with ACSS.
     *
     * @return the configuration value.
     */
    public SapConfiguration configuration() {
        return this.configuration;
    }

    /**
     * Set the configuration property: Defines if the SAP system is being created using Azure Center for SAP solutions
     * (ACSS) or if an existing SAP system is being registered with ACSS.
     *
     * @param configuration the configuration value to set.
     * @return the SapVirtualInstanceProperties object itself.
     */
    public SapVirtualInstanceProperties withConfiguration(SapConfiguration configuration) {
        this.configuration = configuration;
        return this;
    }

    /**
     * Get the managedResourceGroupConfiguration property: Managed resource group configuration.
     *
     * @return the managedResourceGroupConfiguration value.
     */
    public ManagedRGConfiguration managedResourceGroupConfiguration() {
        return this.managedResourceGroupConfiguration;
    }

    /**
     * Set the managedResourceGroupConfiguration property: Managed resource group configuration.
     *
     * @param managedResourceGroupConfiguration the managedResourceGroupConfiguration value to set.
     * @return the SapVirtualInstanceProperties object itself.
     */
    public SapVirtualInstanceProperties withManagedResourceGroupConfiguration(
        ManagedRGConfiguration managedResourceGroupConfiguration) {
        this.managedResourceGroupConfiguration = managedResourceGroupConfiguration;
        return this;
    }

    /**
     * Get the status property: Defines the SAP Instance status.
     *
     * @return the status value.
     */
    public SapVirtualInstanceStatus status() {
        return this.status;
    }

    /**
     * Get the health property: Defines the health of SAP Instances.
     *
     * @return the health value.
     */
    public SapHealthState health() {
        return this.health;
    }

    /**
     * Get the state property: Defines the Virtual Instance for SAP state.
     *
     * @return the state value.
     */
    public SapVirtualInstanceState state() {
        return this.state;
    }

    /**
     * Get the provisioningState property: Defines the provisioning states.
     *
     * @return the provisioningState value.
     */
    public SapVirtualInstanceProvisioningState provisioningState() {
        return this.provisioningState;
    }

    /**
     * Get the errors property: Indicates any errors on the Virtual Instance for SAP solutions resource.
     *
     * @return the errors value.
     */
    public SapVirtualInstanceError errors() {
        return this.errors;
    }

    /**
     * Validates the instance.
     *
     * @throws IllegalArgumentException thrown if the instance is not valid.
     */
    public void validate() {
        if (environment() == null) {
            throw LOGGER
                .logExceptionAsError(
                    new IllegalArgumentException(
                        "Missing required property environment in model SapVirtualInstanceProperties"));
        }
        if (sapProduct() == null) {
            throw LOGGER
                .logExceptionAsError(
                    new IllegalArgumentException(
                        "Missing required property sapProduct in model SapVirtualInstanceProperties"));
        }
        if (configuration() == null) {
            throw LOGGER
                .logExceptionAsError(
                    new IllegalArgumentException(
                        "Missing required property configuration in model SapVirtualInstanceProperties"));
        } else {
            configuration().validate();
        }
        if (managedResourceGroupConfiguration() != null) {
            managedResourceGroupConfiguration().validate();
        }
        if (errors() != null) {
            errors().validate();
        }
    }

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