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

package com.azure.resourcemanager.customerinsights.fluent.models;

import com.azure.core.annotation.Fluent;
import com.azure.core.util.logging.ClientLogger;
import com.azure.resourcemanager.customerinsights.models.CalculationWindowTypes;
import com.azure.resourcemanager.customerinsights.models.EntityTypes;
import com.azure.resourcemanager.customerinsights.models.KpiAlias;
import com.azure.resourcemanager.customerinsights.models.KpiExtract;
import com.azure.resourcemanager.customerinsights.models.KpiFunctions;
import com.azure.resourcemanager.customerinsights.models.KpiGroupByMetadata;
import com.azure.resourcemanager.customerinsights.models.KpiParticipantProfilesMetadata;
import com.azure.resourcemanager.customerinsights.models.KpiThresholds;
import com.azure.resourcemanager.customerinsights.models.ProvisioningStates;
import com.fasterxml.jackson.annotation.JsonInclude;
import com.fasterxml.jackson.annotation.JsonProperty;
import java.util.List;
import java.util.Map;

/** Defines the KPI Threshold limits. */
@Fluent
public class KpiDefinitionInner {
    /*
     * The mapping entity type.
     */
    @JsonProperty(value = "entityType", required = true)
    private EntityTypes entityType;

    /*
     * The mapping entity name.
     */
    @JsonProperty(value = "entityTypeName", required = true)
    private String entityTypeName;

    /*
     * The hub name.
     */
    @JsonProperty(value = "tenantId", access = JsonProperty.Access.WRITE_ONLY)
    private String tenantId;

    /*
     * The KPI name.
     */
    @JsonProperty(value = "kpiName", access = JsonProperty.Access.WRITE_ONLY)
    private String kpiName;

    /*
     * Localized display name for the KPI.
     */
    @JsonProperty(value = "displayName")
    @JsonInclude(value = JsonInclude.Include.NON_NULL, content = JsonInclude.Include.ALWAYS)
    private Map<String, String> displayName;

    /*
     * Localized description for the KPI.
     */
    @JsonProperty(value = "description")
    @JsonInclude(value = JsonInclude.Include.NON_NULL, content = JsonInclude.Include.ALWAYS)
    private Map<String, String> description;

    /*
     * The calculation window.
     */
    @JsonProperty(value = "calculationWindow", required = true)
    private CalculationWindowTypes calculationWindow;

    /*
     * Name of calculation window field.
     */
    @JsonProperty(value = "calculationWindowFieldName")
    private String calculationWindowFieldName;

    /*
     * The computation function for the KPI.
     */
    @JsonProperty(value = "function", required = true)
    private KpiFunctions function;

    /*
     * The computation expression for the KPI.
     */
    @JsonProperty(value = "expression", required = true)
    private String expression;

    /*
     * The unit of measurement for the KPI.
     */
    @JsonProperty(value = "unit")
    private String unit;

    /*
     * The filter expression for the KPI.
     */
    @JsonProperty(value = "filter")
    private String filter;

    /*
     * the group by properties for the KPI.
     */
    @JsonProperty(value = "groupBy")
    private List<String> groupBy;

    /*
     * The KPI GroupByMetadata.
     */
    @JsonProperty(value = "groupByMetadata", access = JsonProperty.Access.WRITE_ONLY)
    private List<KpiGroupByMetadata> groupByMetadata;

    /*
     * The participant profiles.
     */
    @JsonProperty(value = "participantProfilesMetadata", access = JsonProperty.Access.WRITE_ONLY)
    private List<KpiParticipantProfilesMetadata> participantProfilesMetadata;

    /*
     * Provisioning state.
     */
    @JsonProperty(value = "provisioningState", access = JsonProperty.Access.WRITE_ONLY)
    private ProvisioningStates provisioningState;

    /*
     * The KPI thresholds.
     */
    @JsonProperty(value = "thresHolds")
    private KpiThresholds thresHolds;

    /*
     * The aliases.
     */
    @JsonProperty(value = "aliases")
    private List<KpiAlias> aliases;

    /*
     * The KPI extracts.
     */
    @JsonProperty(value = "extracts")
    private List<KpiExtract> extracts;

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

    /**
     * Get the entityType property: The mapping entity type.
     *
     * @return the entityType value.
     */
    public EntityTypes entityType() {
        return this.entityType;
    }

    /**
     * Set the entityType property: The mapping entity type.
     *
     * @param entityType the entityType value to set.
     * @return the KpiDefinitionInner object itself.
     */
    public KpiDefinitionInner withEntityType(EntityTypes entityType) {
        this.entityType = entityType;
        return this;
    }

    /**
     * Get the entityTypeName property: The mapping entity name.
     *
     * @return the entityTypeName value.
     */
    public String entityTypeName() {
        return this.entityTypeName;
    }

    /**
     * Set the entityTypeName property: The mapping entity name.
     *
     * @param entityTypeName the entityTypeName value to set.
     * @return the KpiDefinitionInner object itself.
     */
    public KpiDefinitionInner withEntityTypeName(String entityTypeName) {
        this.entityTypeName = entityTypeName;
        return this;
    }

    /**
     * Get the tenantId property: The hub name.
     *
     * @return the tenantId value.
     */
    public String tenantId() {
        return this.tenantId;
    }

    /**
     * Get the kpiName property: The KPI name.
     *
     * @return the kpiName value.
     */
    public String kpiName() {
        return this.kpiName;
    }

    /**
     * Get the displayName property: Localized display name for the KPI.
     *
     * @return the displayName value.
     */
    public Map<String, String> displayName() {
        return this.displayName;
    }

    /**
     * Set the displayName property: Localized display name for the KPI.
     *
     * @param displayName the displayName value to set.
     * @return the KpiDefinitionInner object itself.
     */
    public KpiDefinitionInner withDisplayName(Map<String, String> displayName) {
        this.displayName = displayName;
        return this;
    }

    /**
     * Get the description property: Localized description for the KPI.
     *
     * @return the description value.
     */
    public Map<String, String> description() {
        return this.description;
    }

    /**
     * Set the description property: Localized description for the KPI.
     *
     * @param description the description value to set.
     * @return the KpiDefinitionInner object itself.
     */
    public KpiDefinitionInner withDescription(Map<String, String> description) {
        this.description = description;
        return this;
    }

    /**
     * Get the calculationWindow property: The calculation window.
     *
     * @return the calculationWindow value.
     */
    public CalculationWindowTypes calculationWindow() {
        return this.calculationWindow;
    }

    /**
     * Set the calculationWindow property: The calculation window.
     *
     * @param calculationWindow the calculationWindow value to set.
     * @return the KpiDefinitionInner object itself.
     */
    public KpiDefinitionInner withCalculationWindow(CalculationWindowTypes calculationWindow) {
        this.calculationWindow = calculationWindow;
        return this;
    }

    /**
     * Get the calculationWindowFieldName property: Name of calculation window field.
     *
     * @return the calculationWindowFieldName value.
     */
    public String calculationWindowFieldName() {
        return this.calculationWindowFieldName;
    }

    /**
     * Set the calculationWindowFieldName property: Name of calculation window field.
     *
     * @param calculationWindowFieldName the calculationWindowFieldName value to set.
     * @return the KpiDefinitionInner object itself.
     */
    public KpiDefinitionInner withCalculationWindowFieldName(String calculationWindowFieldName) {
        this.calculationWindowFieldName = calculationWindowFieldName;
        return this;
    }

    /**
     * Get the function property: The computation function for the KPI.
     *
     * @return the function value.
     */
    public KpiFunctions function() {
        return this.function;
    }

    /**
     * Set the function property: The computation function for the KPI.
     *
     * @param function the function value to set.
     * @return the KpiDefinitionInner object itself.
     */
    public KpiDefinitionInner withFunction(KpiFunctions function) {
        this.function = function;
        return this;
    }

    /**
     * Get the expression property: The computation expression for the KPI.
     *
     * @return the expression value.
     */
    public String expression() {
        return this.expression;
    }

    /**
     * Set the expression property: The computation expression for the KPI.
     *
     * @param expression the expression value to set.
     * @return the KpiDefinitionInner object itself.
     */
    public KpiDefinitionInner withExpression(String expression) {
        this.expression = expression;
        return this;
    }

    /**
     * Get the unit property: The unit of measurement for the KPI.
     *
     * @return the unit value.
     */
    public String unit() {
        return this.unit;
    }

    /**
     * Set the unit property: The unit of measurement for the KPI.
     *
     * @param unit the unit value to set.
     * @return the KpiDefinitionInner object itself.
     */
    public KpiDefinitionInner withUnit(String unit) {
        this.unit = unit;
        return this;
    }

    /**
     * Get the filter property: The filter expression for the KPI.
     *
     * @return the filter value.
     */
    public String filter() {
        return this.filter;
    }

    /**
     * Set the filter property: The filter expression for the KPI.
     *
     * @param filter the filter value to set.
     * @return the KpiDefinitionInner object itself.
     */
    public KpiDefinitionInner withFilter(String filter) {
        this.filter = filter;
        return this;
    }

    /**
     * Get the groupBy property: the group by properties for the KPI.
     *
     * @return the groupBy value.
     */
    public List<String> groupBy() {
        return this.groupBy;
    }

    /**
     * Set the groupBy property: the group by properties for the KPI.
     *
     * @param groupBy the groupBy value to set.
     * @return the KpiDefinitionInner object itself.
     */
    public KpiDefinitionInner withGroupBy(List<String> groupBy) {
        this.groupBy = groupBy;
        return this;
    }

    /**
     * Get the groupByMetadata property: The KPI GroupByMetadata.
     *
     * @return the groupByMetadata value.
     */
    public List<KpiGroupByMetadata> groupByMetadata() {
        return this.groupByMetadata;
    }

    /**
     * Get the participantProfilesMetadata property: The participant profiles.
     *
     * @return the participantProfilesMetadata value.
     */
    public List<KpiParticipantProfilesMetadata> participantProfilesMetadata() {
        return this.participantProfilesMetadata;
    }

    /**
     * Get the provisioningState property: Provisioning state.
     *
     * @return the provisioningState value.
     */
    public ProvisioningStates provisioningState() {
        return this.provisioningState;
    }

    /**
     * Get the thresHolds property: The KPI thresholds.
     *
     * @return the thresHolds value.
     */
    public KpiThresholds thresHolds() {
        return this.thresHolds;
    }

    /**
     * Set the thresHolds property: The KPI thresholds.
     *
     * @param thresHolds the thresHolds value to set.
     * @return the KpiDefinitionInner object itself.
     */
    public KpiDefinitionInner withThresHolds(KpiThresholds thresHolds) {
        this.thresHolds = thresHolds;
        return this;
    }

    /**
     * Get the aliases property: The aliases.
     *
     * @return the aliases value.
     */
    public List<KpiAlias> aliases() {
        return this.aliases;
    }

    /**
     * Set the aliases property: The aliases.
     *
     * @param aliases the aliases value to set.
     * @return the KpiDefinitionInner object itself.
     */
    public KpiDefinitionInner withAliases(List<KpiAlias> aliases) {
        this.aliases = aliases;
        return this;
    }

    /**
     * Get the extracts property: The KPI extracts.
     *
     * @return the extracts value.
     */
    public List<KpiExtract> extracts() {
        return this.extracts;
    }

    /**
     * Set the extracts property: The KPI extracts.
     *
     * @param extracts the extracts value to set.
     * @return the KpiDefinitionInner object itself.
     */
    public KpiDefinitionInner withExtracts(List<KpiExtract> extracts) {
        this.extracts = extracts;
        return this;
    }

    /**
     * Validates the instance.
     *
     * @throws IllegalArgumentException thrown if the instance is not valid.
     */
    public void validate() {
        if (entityType() == null) {
            throw LOGGER
                .logExceptionAsError(
                    new IllegalArgumentException("Missing required property entityType in model KpiDefinitionInner"));
        }
        if (entityTypeName() == null) {
            throw LOGGER
                .logExceptionAsError(
                    new IllegalArgumentException(
                        "Missing required property entityTypeName in model KpiDefinitionInner"));
        }
        if (calculationWindow() == null) {
            throw LOGGER
                .logExceptionAsError(
                    new IllegalArgumentException(
                        "Missing required property calculationWindow in model KpiDefinitionInner"));
        }
        if (function() == null) {
            throw LOGGER
                .logExceptionAsError(
                    new IllegalArgumentException("Missing required property function in model KpiDefinitionInner"));
        }
        if (expression() == null) {
            throw LOGGER
                .logExceptionAsError(
                    new IllegalArgumentException("Missing required property expression in model KpiDefinitionInner"));
        }
        if (groupByMetadata() != null) {
            groupByMetadata().forEach(e -> e.validate());
        }
        if (participantProfilesMetadata() != null) {
            participantProfilesMetadata().forEach(e -> e.validate());
        }
        if (thresHolds() != null) {
            thresHolds().validate();
        }
        if (aliases() != null) {
            aliases().forEach(e -> e.validate());
        }
        if (extracts() != null) {
            extracts().forEach(e -> e.validate());
        }
    }

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