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

package com.azure.resourcemanager.voiceservices.models;

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

/** The service region configuration needed for Teams Callings. */
@Fluent
public final class ServiceRegionProperties {
    /*
     * The name of the region in which the resources needed for Teams Calling will be deployed.
     */
    @JsonProperty(value = "name", required = true)
    private String name;

    /*
     * The configuration used in this region as primary, and other regions as backup.
     */
    @JsonProperty(value = "primaryRegionProperties", required = true)
    private PrimaryRegionProperties primaryRegionProperties;

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

    /**
     * Get the name property: The name of the region in which the resources needed for Teams Calling will be deployed.
     *
     * @return the name value.
     */
    public String name() {
        return this.name;
    }

    /**
     * Set the name property: The name of the region in which the resources needed for Teams Calling will be deployed.
     *
     * @param name the name value to set.
     * @return the ServiceRegionProperties object itself.
     */
    public ServiceRegionProperties withName(String name) {
        this.name = name;
        return this;
    }

    /**
     * Get the primaryRegionProperties property: The configuration used in this region as primary, and other regions as
     * backup.
     *
     * @return the primaryRegionProperties value.
     */
    public PrimaryRegionProperties primaryRegionProperties() {
        return this.primaryRegionProperties;
    }

    /**
     * Set the primaryRegionProperties property: The configuration used in this region as primary, and other regions as
     * backup.
     *
     * @param primaryRegionProperties the primaryRegionProperties value to set.
     * @return the ServiceRegionProperties object itself.
     */
    public ServiceRegionProperties withPrimaryRegionProperties(PrimaryRegionProperties primaryRegionProperties) {
        this.primaryRegionProperties = primaryRegionProperties;
        return this;
    }

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

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