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

package com.azure.resourcemanager.deploymentmanager.models;

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

/** Defines the properties of a service unit. */
@Fluent
public class ServiceUnitProperties {
    /*
     * The Azure Resource Group to which the resources in the service unit belong to or should be deployed to.
     */
    @JsonProperty(value = "targetResourceGroup", required = true)
    private String targetResourceGroup;

    /*
     * Describes the type of ARM deployment to be performed on the resource.
     */
    @JsonProperty(value = "deploymentMode", required = true)
    private DeploymentMode deploymentMode;

    /*
     * The artifacts for the service unit.
     */
    @JsonProperty(value = "artifacts")
    private ServiceUnitArtifacts artifacts;

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

    /**
     * Get the targetResourceGroup property: The Azure Resource Group to which the resources in the service unit belong
     * to or should be deployed to.
     *
     * @return the targetResourceGroup value.
     */
    public String targetResourceGroup() {
        return this.targetResourceGroup;
    }

    /**
     * Set the targetResourceGroup property: The Azure Resource Group to which the resources in the service unit belong
     * to or should be deployed to.
     *
     * @param targetResourceGroup the targetResourceGroup value to set.
     * @return the ServiceUnitProperties object itself.
     */
    public ServiceUnitProperties withTargetResourceGroup(String targetResourceGroup) {
        this.targetResourceGroup = targetResourceGroup;
        return this;
    }

    /**
     * Get the deploymentMode property: Describes the type of ARM deployment to be performed on the resource.
     *
     * @return the deploymentMode value.
     */
    public DeploymentMode deploymentMode() {
        return this.deploymentMode;
    }

    /**
     * Set the deploymentMode property: Describes the type of ARM deployment to be performed on the resource.
     *
     * @param deploymentMode the deploymentMode value to set.
     * @return the ServiceUnitProperties object itself.
     */
    public ServiceUnitProperties withDeploymentMode(DeploymentMode deploymentMode) {
        this.deploymentMode = deploymentMode;
        return this;
    }

    /**
     * Get the artifacts property: The artifacts for the service unit.
     *
     * @return the artifacts value.
     */
    public ServiceUnitArtifacts artifacts() {
        return this.artifacts;
    }

    /**
     * Set the artifacts property: The artifacts for the service unit.
     *
     * @param artifacts the artifacts value to set.
     * @return the ServiceUnitProperties object itself.
     */
    public ServiceUnitProperties withArtifacts(ServiceUnitArtifacts artifacts) {
        this.artifacts = artifacts;
        return this;
    }

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

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