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

package com.azure.resourcemanager.securityinsights.models;

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

/** Represents a supported source signal configuration in Fusion detection. */
@Fluent
public final class FusionSourceSettings {
    /*
     * Determines whether this source signal is enabled or disabled in Fusion detection.
     */
    @JsonProperty(value = "enabled", required = true)
    private boolean enabled;

    /*
     * Name of the Fusion source signal. Refer to Fusion alert rule template for supported values.
     */
    @JsonProperty(value = "sourceName", required = true)
    private String sourceName;

    /*
     * Configuration for all source subtypes under this source signal consumed in fusion detection.
     */
    @JsonProperty(value = "sourceSubTypes")
    private List<FusionSourceSubTypeSetting> sourceSubTypes;

    /**
     * Get the enabled property: Determines whether this source signal is enabled or disabled in Fusion detection.
     *
     * @return the enabled value.
     */
    public boolean enabled() {
        return this.enabled;
    }

    /**
     * Set the enabled property: Determines whether this source signal is enabled or disabled in Fusion detection.
     *
     * @param enabled the enabled value to set.
     * @return the FusionSourceSettings object itself.
     */
    public FusionSourceSettings withEnabled(boolean enabled) {
        this.enabled = enabled;
        return this;
    }

    /**
     * Get the sourceName property: Name of the Fusion source signal. Refer to Fusion alert rule template for supported
     * values.
     *
     * @return the sourceName value.
     */
    public String sourceName() {
        return this.sourceName;
    }

    /**
     * Set the sourceName property: Name of the Fusion source signal. Refer to Fusion alert rule template for supported
     * values.
     *
     * @param sourceName the sourceName value to set.
     * @return the FusionSourceSettings object itself.
     */
    public FusionSourceSettings withSourceName(String sourceName) {
        this.sourceName = sourceName;
        return this;
    }

    /**
     * Get the sourceSubTypes property: Configuration for all source subtypes under this source signal consumed in
     * fusion detection.
     *
     * @return the sourceSubTypes value.
     */
    public List<FusionSourceSubTypeSetting> sourceSubTypes() {
        return this.sourceSubTypes;
    }

    /**
     * Set the sourceSubTypes property: Configuration for all source subtypes under this source signal consumed in
     * fusion detection.
     *
     * @param sourceSubTypes the sourceSubTypes value to set.
     * @return the FusionSourceSettings object itself.
     */
    public FusionSourceSettings withSourceSubTypes(List<FusionSourceSubTypeSetting> sourceSubTypes) {
        this.sourceSubTypes = sourceSubTypes;
        return this;
    }

    /**
     * Validates the instance.
     *
     * @throws IllegalArgumentException thrown if the instance is not valid.
     */
    public void validate() {
        if (sourceName() == null) {
            throw LOGGER
                .logExceptionAsError(
                    new IllegalArgumentException("Missing required property sourceName in model FusionSourceSettings"));
        }
        if (sourceSubTypes() != null) {
            sourceSubTypes().forEach(e -> e.validate());
        }
    }

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