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

package com.azure.resourcemanager.batchai.models;

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

/** Azure Application Insights information for performance counters reporting. */
@Fluent
public final class AppInsightsReference {
    @JsonIgnore private final ClientLogger logger = new ClientLogger(AppInsightsReference.class);

    /*
     * Azure Application Insights component resource ID.
     */
    @JsonProperty(value = "component", required = true)
    private ResourceId component;

    /*
     * Value of the Azure Application Insights instrumentation key.
     */
    @JsonProperty(value = "instrumentationKey")
    private String instrumentationKey;

    /*
     * KeyVault Store and Secret which contains Azure Application Insights
     * instrumentation key. One of instrumentationKey or
     * instrumentationKeySecretReference must be specified.
     */
    @JsonProperty(value = "instrumentationKeySecretReference")
    private KeyVaultSecretReference instrumentationKeySecretReference;

    /**
     * Get the component property: Azure Application Insights component resource ID.
     *
     * @return the component value.
     */
    public ResourceId component() {
        return this.component;
    }

    /**
     * Set the component property: Azure Application Insights component resource ID.
     *
     * @param component the component value to set.
     * @return the AppInsightsReference object itself.
     */
    public AppInsightsReference withComponent(ResourceId component) {
        this.component = component;
        return this;
    }

    /**
     * Get the instrumentationKey property: Value of the Azure Application Insights instrumentation key.
     *
     * @return the instrumentationKey value.
     */
    public String instrumentationKey() {
        return this.instrumentationKey;
    }

    /**
     * Set the instrumentationKey property: Value of the Azure Application Insights instrumentation key.
     *
     * @param instrumentationKey the instrumentationKey value to set.
     * @return the AppInsightsReference object itself.
     */
    public AppInsightsReference withInstrumentationKey(String instrumentationKey) {
        this.instrumentationKey = instrumentationKey;
        return this;
    }

    /**
     * Get the instrumentationKeySecretReference property: KeyVault Store and Secret which contains Azure Application
     * Insights instrumentation key. One of instrumentationKey or instrumentationKeySecretReference must be specified.
     *
     * @return the instrumentationKeySecretReference value.
     */
    public KeyVaultSecretReference instrumentationKeySecretReference() {
        return this.instrumentationKeySecretReference;
    }

    /**
     * Set the instrumentationKeySecretReference property: KeyVault Store and Secret which contains Azure Application
     * Insights instrumentation key. One of instrumentationKey or instrumentationKeySecretReference must be specified.
     *
     * @param instrumentationKeySecretReference the instrumentationKeySecretReference value to set.
     * @return the AppInsightsReference object itself.
     */
    public AppInsightsReference withInstrumentationKeySecretReference(
        KeyVaultSecretReference instrumentationKeySecretReference) {
        this.instrumentationKeySecretReference = instrumentationKeySecretReference;
        return this;
    }

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