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

package com.azure.resourcemanager.azureadexternalidentities.models;

import com.azure.core.annotation.Fluent;
import com.azure.core.util.logging.ClientLogger;
import com.azure.resourcemanager.azureadexternalidentities.fluent.models.CreateTenantRequestBodyProperties;
import com.fasterxml.jackson.annotation.JsonInclude;
import com.fasterxml.jackson.annotation.JsonProperty;
import java.util.Map;

/**
 * The information needed to create the Azure AD B2C tenant and corresponding Azure resource, which is used for billing
 * purposes.
 */
@Fluent
public final class CreateTenantRequestBody {
    /*
     * The location in which the resource is hosted and data resides. Can be
     * one of 'United States', 'Europe', 'Asia Pacific', or 'Australia'. Refer
     * to [this documentation](https://aka.ms/B2CDataResidency) for more
     * information.
     */
    @JsonProperty(value = "location", required = true)
    private String location;

    /*
     * The properties property.
     */
    @JsonProperty(value = "properties", required = true)
    private CreateTenantRequestBodyProperties innerProperties = new CreateTenantRequestBodyProperties();

    /*
     * SKU properties of the Azure AD B2C tenant. Learn more about Azure AD B2C
     * billing at [aka.ms/b2cBilling](https://aka.ms/b2cBilling).
     */
    @JsonProperty(value = "sku", required = true)
    private B2CResourceSku sku;

    /*
     * Resource Tags
     */
    @JsonProperty(value = "tags")
    @JsonInclude(value = JsonInclude.Include.NON_NULL, content = JsonInclude.Include.ALWAYS)
    private Map<String, String> tags;

    /**
     * Get the location property: The location in which the resource is hosted and data resides. Can be one of 'United
     * States', 'Europe', 'Asia Pacific', or 'Australia'. Refer to [this documentation](https://aka.ms/B2CDataResidency)
     * for more information.
     *
     * @return the location value.
     */
    public String location() {
        return this.location;
    }

    /**
     * Set the location property: The location in which the resource is hosted and data resides. Can be one of 'United
     * States', 'Europe', 'Asia Pacific', or 'Australia'. Refer to [this documentation](https://aka.ms/B2CDataResidency)
     * for more information.
     *
     * @param location the location value to set.
     * @return the CreateTenantRequestBody object itself.
     */
    public CreateTenantRequestBody withLocation(String location) {
        this.location = location;
        return this;
    }

    /**
     * Get the innerProperties property: The properties property.
     *
     * @return the innerProperties value.
     */
    private CreateTenantRequestBodyProperties innerProperties() {
        return this.innerProperties;
    }

    /**
     * Get the sku property: SKU properties of the Azure AD B2C tenant. Learn more about Azure AD B2C billing at
     * [aka.ms/b2cBilling](https://aka.ms/b2cBilling).
     *
     * @return the sku value.
     */
    public B2CResourceSku sku() {
        return this.sku;
    }

    /**
     * Set the sku property: SKU properties of the Azure AD B2C tenant. Learn more about Azure AD B2C billing at
     * [aka.ms/b2cBilling](https://aka.ms/b2cBilling).
     *
     * @param sku the sku value to set.
     * @return the CreateTenantRequestBody object itself.
     */
    public CreateTenantRequestBody withSku(B2CResourceSku sku) {
        this.sku = sku;
        return this;
    }

    /**
     * Get the tags property: Resource Tags.
     *
     * @return the tags value.
     */
    public Map<String, String> tags() {
        return this.tags;
    }

    /**
     * Set the tags property: Resource Tags.
     *
     * @param tags the tags value to set.
     * @return the CreateTenantRequestBody object itself.
     */
    public CreateTenantRequestBody withTags(Map<String, String> tags) {
        this.tags = tags;
        return this;
    }

    /**
     * Get the displayName property: The display name of the Azure AD B2C tenant.
     *
     * @return the displayName value.
     */
    public String displayName() {
        return this.innerProperties() == null ? null : this.innerProperties().displayName();
    }

    /**
     * Set the displayName property: The display name of the Azure AD B2C tenant.
     *
     * @param displayName the displayName value to set.
     * @return the CreateTenantRequestBody object itself.
     */
    public CreateTenantRequestBody withDisplayName(String displayName) {
        if (this.innerProperties() == null) {
            this.innerProperties = new CreateTenantRequestBodyProperties();
        }
        this.innerProperties().withDisplayName(displayName);
        return this;
    }

    /**
     * Get the countryCode property: Country code of Azure tenant (e.g. 'US'). Refer to
     * [aka.ms/B2CDataResidency](https://aka.ms/B2CDataResidency) to see valid country codes and corresponding data
     * residency locations. If you do not see a country code in an valid data residency location, choose one from the
     * list.
     *
     * @return the countryCode value.
     */
    public String countryCode() {
        return this.innerProperties() == null ? null : this.innerProperties().countryCode();
    }

    /**
     * Set the countryCode property: Country code of Azure tenant (e.g. 'US'). Refer to
     * [aka.ms/B2CDataResidency](https://aka.ms/B2CDataResidency) to see valid country codes and corresponding data
     * residency locations. If you do not see a country code in an valid data residency location, choose one from the
     * list.
     *
     * @param countryCode the countryCode value to set.
     * @return the CreateTenantRequestBody object itself.
     */
    public CreateTenantRequestBody withCountryCode(String countryCode) {
        if (this.innerProperties() == null) {
            this.innerProperties = new CreateTenantRequestBodyProperties();
        }
        this.innerProperties().withCountryCode(countryCode);
        return this;
    }

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

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