// 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.management.Resource;
import com.azure.core.management.SystemData;
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.azure.resourcemanager.workloads.models.UserAssignedServiceIdentity;
import com.fasterxml.jackson.annotation.JsonProperty;
import java.util.Map;

/** Define the Virtual Instance for SAP solutions resource. */
@Fluent
public final class SapVirtualInstanceInner extends Resource {
    /*
     * A pre-created user assigned identity with appropriate roles assigned. To learn more on identity and roles
     * required, visit the ACSS how-to-guide.
     */
    @JsonProperty(value = "identity")
    private UserAssignedServiceIdentity identity;

    /*
     * Defines the Virtual Instance for SAP solutions resource properties.
     */
    @JsonProperty(value = "properties", required = true)
    private SapVirtualInstanceProperties innerProperties = new SapVirtualInstanceProperties();

    /*
     * Azure Resource Manager metadata containing createdBy and modifiedBy information.
     */
    @JsonProperty(value = "systemData", access = JsonProperty.Access.WRITE_ONLY)
    private SystemData systemData;

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

    /**
     * Get the identity property: A pre-created user assigned identity with appropriate roles assigned. To learn more on
     * identity and roles required, visit the ACSS how-to-guide.
     *
     * @return the identity value.
     */
    public UserAssignedServiceIdentity identity() {
        return this.identity;
    }

    /**
     * Set the identity property: A pre-created user assigned identity with appropriate roles assigned. To learn more on
     * identity and roles required, visit the ACSS how-to-guide.
     *
     * @param identity the identity value to set.
     * @return the SapVirtualInstanceInner object itself.
     */
    public SapVirtualInstanceInner withIdentity(UserAssignedServiceIdentity identity) {
        this.identity = identity;
        return this;
    }

    /**
     * Get the innerProperties property: Defines the Virtual Instance for SAP solutions resource properties.
     *
     * @return the innerProperties value.
     */
    private SapVirtualInstanceProperties innerProperties() {
        return this.innerProperties;
    }

    /**
     * Get the systemData property: Azure Resource Manager metadata containing createdBy and modifiedBy information.
     *
     * @return the systemData value.
     */
    public SystemData systemData() {
        return this.systemData;
    }

    /** {@inheritDoc} */
    @Override
    public SapVirtualInstanceInner withLocation(String location) {
        super.withLocation(location);
        return this;
    }

    /** {@inheritDoc} */
    @Override
    public SapVirtualInstanceInner withTags(Map<String, String> tags) {
        super.withTags(tags);
        return this;
    }

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

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

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

    /**
     * Set the sapProduct property: Defines the SAP Product type.
     *
     * @param sapProduct the sapProduct value to set.
     * @return the SapVirtualInstanceInner object itself.
     */
    public SapVirtualInstanceInner withSapProduct(SapProductType sapProduct) {
        if (this.innerProperties() == null) {
            this.innerProperties = new SapVirtualInstanceProperties();
        }
        this.innerProperties().withSapProduct(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.innerProperties() == null ? null : this.innerProperties().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 SapVirtualInstanceInner object itself.
     */
    public SapVirtualInstanceInner withConfiguration(SapConfiguration configuration) {
        if (this.innerProperties() == null) {
            this.innerProperties = new SapVirtualInstanceProperties();
        }
        this.innerProperties().withConfiguration(configuration);
        return this;
    }

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

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

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

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

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

    /**
     * Get the provisioningState property: Defines the provisioning states.
     *
     * @return the provisioningState value.
     */
    public SapVirtualInstanceProvisioningState provisioningState() {
        return this.innerProperties() == null ? null : this.innerProperties().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.innerProperties() == null ? null : this.innerProperties().errors();
    }

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

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