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

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

import com.azure.core.annotation.Fluent;
import com.azure.core.util.logging.ClientLogger;
import com.azure.resourcemanager.automation.models.ContentSource;
import com.azure.resourcemanager.automation.models.DscConfigurationParameter;
import com.fasterxml.jackson.annotation.JsonInclude;
import com.fasterxml.jackson.annotation.JsonProperty;
import java.util.Map;

/** The properties to create or update configuration. */
@Fluent
public final class DscConfigurationCreateOrUpdateProperties {
    /*
     * Gets or sets verbose log option.
     */
    @JsonProperty(value = "logVerbose")
    private Boolean logVerbose;

    /*
     * Gets or sets progress log option.
     */
    @JsonProperty(value = "logProgress")
    private Boolean logProgress;

    /*
     * Gets or sets the source.
     */
    @JsonProperty(value = "source", required = true)
    private ContentSource source;

    /*
     * Gets or sets the configuration parameters.
     */
    @JsonProperty(value = "parameters")
    @JsonInclude(value = JsonInclude.Include.NON_NULL, content = JsonInclude.Include.ALWAYS)
    private Map<String, DscConfigurationParameter> parameters;

    /*
     * Gets or sets the description of the configuration.
     */
    @JsonProperty(value = "description")
    private String description;

    /**
     * Get the logVerbose property: Gets or sets verbose log option.
     *
     * @return the logVerbose value.
     */
    public Boolean logVerbose() {
        return this.logVerbose;
    }

    /**
     * Set the logVerbose property: Gets or sets verbose log option.
     *
     * @param logVerbose the logVerbose value to set.
     * @return the DscConfigurationCreateOrUpdateProperties object itself.
     */
    public DscConfigurationCreateOrUpdateProperties withLogVerbose(Boolean logVerbose) {
        this.logVerbose = logVerbose;
        return this;
    }

    /**
     * Get the logProgress property: Gets or sets progress log option.
     *
     * @return the logProgress value.
     */
    public Boolean logProgress() {
        return this.logProgress;
    }

    /**
     * Set the logProgress property: Gets or sets progress log option.
     *
     * @param logProgress the logProgress value to set.
     * @return the DscConfigurationCreateOrUpdateProperties object itself.
     */
    public DscConfigurationCreateOrUpdateProperties withLogProgress(Boolean logProgress) {
        this.logProgress = logProgress;
        return this;
    }

    /**
     * Get the source property: Gets or sets the source.
     *
     * @return the source value.
     */
    public ContentSource source() {
        return this.source;
    }

    /**
     * Set the source property: Gets or sets the source.
     *
     * @param source the source value to set.
     * @return the DscConfigurationCreateOrUpdateProperties object itself.
     */
    public DscConfigurationCreateOrUpdateProperties withSource(ContentSource source) {
        this.source = source;
        return this;
    }

    /**
     * Get the parameters property: Gets or sets the configuration parameters.
     *
     * @return the parameters value.
     */
    public Map<String, DscConfigurationParameter> parameters() {
        return this.parameters;
    }

    /**
     * Set the parameters property: Gets or sets the configuration parameters.
     *
     * @param parameters the parameters value to set.
     * @return the DscConfigurationCreateOrUpdateProperties object itself.
     */
    public DscConfigurationCreateOrUpdateProperties withParameters(Map<String, DscConfigurationParameter> parameters) {
        this.parameters = parameters;
        return this;
    }

    /**
     * Get the description property: Gets or sets the description of the configuration.
     *
     * @return the description value.
     */
    public String description() {
        return this.description;
    }

    /**
     * Set the description property: Gets or sets the description of the configuration.
     *
     * @param description the description value to set.
     * @return the DscConfigurationCreateOrUpdateProperties object itself.
     */
    public DscConfigurationCreateOrUpdateProperties withDescription(String description) {
        this.description = description;
        return this;
    }

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

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