All Downloads are FREE. Search and download functionalities are using the official Maven repository.

com.azure.resourcemanager.automation.models.VariableCreateOrUpdateParameters Maven / Gradle / Ivy

Go to download

This package contains Microsoft Azure SDK for Automation Management SDK. For documentation on how to use this package, please see https://aka.ms/azsdk/java/mgmt. Automation Client. Package tag package-2022-02-22.

The newest version!
// 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.json.JsonReader;
import com.azure.json.JsonSerializable;
import com.azure.json.JsonToken;
import com.azure.json.JsonWriter;
import com.azure.resourcemanager.automation.fluent.models.VariableCreateOrUpdateProperties;
import java.io.IOException;

/**
 * The parameters supplied to the create or update variable operation.
 */
@Fluent
public final class VariableCreateOrUpdateParameters implements JsonSerializable {
    /*
     * Gets or sets the name of the variable.
     */
    private String name;

    /*
     * Gets or sets the properties of the variable.
     */
    private VariableCreateOrUpdateProperties innerProperties = new VariableCreateOrUpdateProperties();

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

    /**
     * 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.atError()
                .log(new IllegalArgumentException(
                    "Missing required property name in model VariableCreateOrUpdateParameters"));
        }
        if (innerProperties() == null) {
            throw LOGGER.atError()
                .log(new IllegalArgumentException(
                    "Missing required property innerProperties in model VariableCreateOrUpdateParameters"));
        } else {
            innerProperties().validate();
        }
    }

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

    /**
     * {@inheritDoc}
     */
    @Override
    public JsonWriter toJson(JsonWriter jsonWriter) throws IOException {
        jsonWriter.writeStartObject();
        jsonWriter.writeStringField("name", this.name);
        jsonWriter.writeJsonField("properties", this.innerProperties);
        return jsonWriter.writeEndObject();
    }

    /**
     * Reads an instance of VariableCreateOrUpdateParameters from the JsonReader.
     * 
     * @param jsonReader The JsonReader being read.
     * @return An instance of VariableCreateOrUpdateParameters if the JsonReader was pointing to an instance of it, or
     * null if it was pointing to JSON null.
     * @throws IllegalStateException If the deserialized JSON object was missing any required properties.
     * @throws IOException If an error occurs while reading the VariableCreateOrUpdateParameters.
     */
    public static VariableCreateOrUpdateParameters fromJson(JsonReader jsonReader) throws IOException {
        return jsonReader.readObject(reader -> {
            VariableCreateOrUpdateParameters deserializedVariableCreateOrUpdateParameters
                = new VariableCreateOrUpdateParameters();
            while (reader.nextToken() != JsonToken.END_OBJECT) {
                String fieldName = reader.getFieldName();
                reader.nextToken();

                if ("name".equals(fieldName)) {
                    deserializedVariableCreateOrUpdateParameters.name = reader.getString();
                } else if ("properties".equals(fieldName)) {
                    deserializedVariableCreateOrUpdateParameters.innerProperties
                        = VariableCreateOrUpdateProperties.fromJson(reader);
                } else {
                    reader.skipChildren();
                }
            }

            return deserializedVariableCreateOrUpdateParameters;
        });
    }
}




© 2015 - 2024 Weber Informatics LLC | Privacy Policy