// 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.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.azureadexternalidentities.models.B2CResourceSku;
import com.azure.resourcemanager.azureadexternalidentities.models.B2CTenantResourcePropertiesBillingConfig;
import com.fasterxml.jackson.annotation.JsonProperty;
import java.util.Map;

/** The B2CTenantResource model. */
@Fluent
public final class B2CTenantResourceInner extends Resource {
    /*
     * 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;

    /*
     * The Azure AD B2C tenant resource properties
     */
    @JsonProperty(value = "properties")
    private B2CTenantResourceProperties innerProperties;

    /*
     * Metadata pertaining to creation and last modification of the resource.
     */
    @JsonProperty(value = "systemData", access = JsonProperty.Access.WRITE_ONLY)
    private SystemData systemData;

    /**
     * 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 B2CTenantResourceInner object itself.
     */
    public B2CTenantResourceInner withSku(B2CResourceSku sku) {
        this.sku = sku;
        return this;
    }

    /**
     * Get the innerProperties property: The Azure AD B2C tenant resource properties.
     *
     * @return the innerProperties value.
     */
    private B2CTenantResourceProperties innerProperties() {
        return this.innerProperties;
    }

    /**
     * Get the systemData property: Metadata pertaining to creation and last modification of the resource.
     *
     * @return the systemData value.
     */
    public SystemData systemData() {
        return this.systemData;
    }

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

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

    /**
     * Get the billingConfig property: The billing configuration for the tenant.
     *
     * @return the billingConfig value.
     */
    public B2CTenantResourcePropertiesBillingConfig billingConfig() {
        return this.innerProperties() == null ? null : this.innerProperties().billingConfig();
    }

    /**
     * Set the billingConfig property: The billing configuration for the tenant.
     *
     * @param billingConfig the billingConfig value to set.
     * @return the B2CTenantResourceInner object itself.
     */
    public B2CTenantResourceInner withBillingConfig(B2CTenantResourcePropertiesBillingConfig billingConfig) {
        if (this.innerProperties() == null) {
            this.innerProperties = new B2CTenantResourceProperties();
        }
        this.innerProperties().withBillingConfig(billingConfig);
        return this;
    }

    /**
     * Get the tenantId property: An identifier of the Azure AD B2C tenant.
     *
     * @return the tenantId value.
     */
    public String tenantId() {
        return this.innerProperties() == null ? null : this.innerProperties().tenantId();
    }

    /**
     * Set the tenantId property: An identifier of the Azure AD B2C tenant.
     *
     * @param tenantId the tenantId value to set.
     * @return the B2CTenantResourceInner object itself.
     */
    public B2CTenantResourceInner withTenantId(String tenantId) {
        if (this.innerProperties() == null) {
            this.innerProperties = new B2CTenantResourceProperties();
        }
        this.innerProperties().withTenantId(tenantId);
        return this;
    }

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

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