// 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.fluent.models;

import com.azure.core.annotation.Fluent;
import com.azure.core.management.Resource;
import com.azure.core.util.logging.ClientLogger;
import com.azure.resourcemanager.deploymentmanager.models.DeploymentMode;
import com.azure.resourcemanager.deploymentmanager.models.ServiceUnitArtifacts;
import com.fasterxml.jackson.annotation.JsonProperty;
import java.util.Map;

/** Represents the response of a service unit resource. */
@Fluent
public final class ServiceUnitResourceInner extends Resource {
    /*
     * The properties that define the service unit.
     */
    @JsonProperty(value = "properties", required = true)
    private ServiceUnitResourceProperties innerProperties = new ServiceUnitResourceProperties();

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

    /**
     * Get the innerProperties property: The properties that define the service unit.
     *
     * @return the innerProperties value.
     */
    private ServiceUnitResourceProperties innerProperties() {
        return this.innerProperties;
    }

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

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

    /**
     * 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.innerProperties() == null ? null : this.innerProperties().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 ServiceUnitResourceInner object itself.
     */
    public ServiceUnitResourceInner withTargetResourceGroup(String targetResourceGroup) {
        if (this.innerProperties() == null) {
            this.innerProperties = new ServiceUnitResourceProperties();
        }
        this.innerProperties().withTargetResourceGroup(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.innerProperties() == null ? null : this.innerProperties().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 ServiceUnitResourceInner object itself.
     */
    public ServiceUnitResourceInner withDeploymentMode(DeploymentMode deploymentMode) {
        if (this.innerProperties() == null) {
            this.innerProperties = new ServiceUnitResourceProperties();
        }
        this.innerProperties().withDeploymentMode(deploymentMode);
        return this;
    }

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

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

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

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