// 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.models;

import com.azure.core.annotation.Fluent;
import com.azure.core.util.logging.ClientLogger;
import com.azure.resourcemanager.automation.fluent.models.VariableCreateOrUpdateProperties;
import com.fasterxml.jackson.annotation.JsonProperty;

/** The parameters supplied to the create or update variable operation. */
@Fluent
public final class VariableCreateOrUpdateParameters {
    /*
     * Gets or sets the name of the variable.
     */
    @JsonProperty(value = "name", required = true)
    private String name;

    /*
     * Gets or sets the properties of the variable.
     */
    @JsonProperty(value = "properties", required = true)
    private VariableCreateOrUpdateProperties innerProperties = new VariableCreateOrUpdateProperties();

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

    /**
     * Set the name property: Gets or sets the name of the variable.
     *
     * @param name the name value to set.
     * @return the VariableCreateOrUpdateParameters object itself.
     */
    public VariableCreateOrUpdateParameters withName(String name) {
        this.name = name;
        return this;
    }

    /**
     * Get the innerProperties property: Gets or sets the properties of the variable.
     *
     * @return the innerProperties value.
     */
    private VariableCreateOrUpdateProperties innerProperties() {
        return this.innerProperties;
    }

    /**
     * Get the value property: Gets or sets the value of the variable.
     *
     * @return the value value.
     */
    public String value() {
        return this.innerProperties() == null ? null : this.innerProperties().value();
    }

    /**
     * Set the value property: Gets or sets the value of the variable.
     *
     * @param value the value value to set.
     * @return the VariableCreateOrUpdateParameters object itself.
     */
    public VariableCreateOrUpdateParameters withValue(String value) {
        if (this.innerProperties() == null) {
            this.innerProperties = new VariableCreateOrUpdateProperties();
        }
        this.innerProperties().withValue(value);
        return this;
    }

    /**
     * Get the description property: Gets or sets the description of the variable.
     *
     * @return the description value.
     */
    public String description() {
        return this.innerProperties() == null ? null : this.innerProperties().description();
    }

    /**
     * Set the description property: Gets or sets the description of the variable.
     *
     * @param description the description value to set.
     * @return the VariableCreateOrUpdateParameters object itself.
     */
    public VariableCreateOrUpdateParameters withDescription(String description) {
        if (this.innerProperties() == null) {
            this.innerProperties = new VariableCreateOrUpdateProperties();
        }
        this.innerProperties().withDescription(description);
        return this;
    }

    /**
     * Get the isEncrypted property: Gets or sets the encrypted flag of the variable.
     *
     * @return the isEncrypted value.
     */
    public Boolean isEncrypted() {
        return this.innerProperties() == null ? null : this.innerProperties().isEncrypted();
    }

    /**
     * Set the isEncrypted property: Gets or sets the encrypted flag of the variable.
     *
     * @param isEncrypted the isEncrypted value to set.
     * @return the VariableCreateOrUpdateParameters object itself.
     */
    public VariableCreateOrUpdateParameters withIsEncrypted(Boolean isEncrypted) {
        if (this.innerProperties() == null) {
            this.innerProperties = new VariableCreateOrUpdateProperties();
        }
        this.innerProperties().withIsEncrypted(isEncrypted);
        return this;
    }

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

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