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

com.azure.resourcemanager.avs.fluent.models.ScriptExecutionProperties Maven / Gradle / Ivy

Go to download

This package contains Microsoft Azure SDK for Avs Management SDK. For documentation on how to use this package, please see https://aka.ms/azsdk/java/mgmt. Azure VMware Solution API. Package tag package-2023-09-01.

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.avs.fluent.models;

import com.azure.core.annotation.Fluent;
import com.azure.core.util.CoreUtils;
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.avs.models.ScriptExecutionParameter;
import com.azure.resourcemanager.avs.models.ScriptExecutionProvisioningState;
import java.io.IOException;
import java.time.OffsetDateTime;
import java.util.List;
import java.util.Map;

/**
 * Properties of a user-invoked script.
 */
@Fluent
public final class ScriptExecutionProperties implements JsonSerializable {
    /*
     * A reference to the script cmdlet resource if user is running a AVS script
     */
    private String scriptCmdletId;

    /*
     * Parameters the script will accept
     */
    private List parameters;

    /*
     * Parameters that will be hidden/not visible to ARM, such as passwords and
     * credentials
     */
    private List hiddenParameters;

    /*
     * Error message if the script was able to run, but if the script itself had
     * errors or powershell threw an exception
     */
    private String failureReason;

    /*
     * Time limit for execution
     */
    private String timeout;

    /*
     * Time to live for the resource. If not provided, will be available for 60 days
     */
    private String retention;

    /*
     * Time the script execution was submitted
     */
    private OffsetDateTime submittedAt;

    /*
     * Time the script execution was started
     */
    private OffsetDateTime startedAt;

    /*
     * Time the script execution was finished
     */
    private OffsetDateTime finishedAt;

    /*
     * The state of the script execution resource
     */
    private ScriptExecutionProvisioningState provisioningState;

    /*
     * Standard output stream from the powershell execution
     */
    private List output;

    /*
     * User-defined dictionary.
     */
    private Map namedOutputs;

    /*
     * Standard information out stream from the powershell execution
     */
    private List information;

    /*
     * Standard warning out stream from the powershell execution
     */
    private List warnings;

    /*
     * Standard error output stream from the powershell execution
     */
    private List errors;

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

    /**
     * Get the scriptCmdletId property: A reference to the script cmdlet resource if user is running a AVS script.
     * 
     * @return the scriptCmdletId value.
     */
    public String scriptCmdletId() {
        return this.scriptCmdletId;
    }

    /**
     * Set the scriptCmdletId property: A reference to the script cmdlet resource if user is running a AVS script.
     * 
     * @param scriptCmdletId the scriptCmdletId value to set.
     * @return the ScriptExecutionProperties object itself.
     */
    public ScriptExecutionProperties withScriptCmdletId(String scriptCmdletId) {
        this.scriptCmdletId = scriptCmdletId;
        return this;
    }

    /**
     * Get the parameters property: Parameters the script will accept.
     * 
     * @return the parameters value.
     */
    public List parameters() {
        return this.parameters;
    }

    /**
     * Set the parameters property: Parameters the script will accept.
     * 
     * @param parameters the parameters value to set.
     * @return the ScriptExecutionProperties object itself.
     */
    public ScriptExecutionProperties withParameters(List parameters) {
        this.parameters = parameters;
        return this;
    }

    /**
     * Get the hiddenParameters property: Parameters that will be hidden/not visible to ARM, such as passwords and
     * credentials.
     * 
     * @return the hiddenParameters value.
     */
    public List hiddenParameters() {
        return this.hiddenParameters;
    }

    /**
     * Set the hiddenParameters property: Parameters that will be hidden/not visible to ARM, such as passwords and
     * credentials.
     * 
     * @param hiddenParameters the hiddenParameters value to set.
     * @return the ScriptExecutionProperties object itself.
     */
    public ScriptExecutionProperties withHiddenParameters(List hiddenParameters) {
        this.hiddenParameters = hiddenParameters;
        return this;
    }

    /**
     * Get the failureReason property: Error message if the script was able to run, but if the script itself had
     * errors or powershell threw an exception.
     * 
     * @return the failureReason value.
     */
    public String failureReason() {
        return this.failureReason;
    }

    /**
     * Set the failureReason property: Error message if the script was able to run, but if the script itself had
     * errors or powershell threw an exception.
     * 
     * @param failureReason the failureReason value to set.
     * @return the ScriptExecutionProperties object itself.
     */
    public ScriptExecutionProperties withFailureReason(String failureReason) {
        this.failureReason = failureReason;
        return this;
    }

    /**
     * Get the timeout property: Time limit for execution.
     * 
     * @return the timeout value.
     */
    public String timeout() {
        return this.timeout;
    }

    /**
     * Set the timeout property: Time limit for execution.
     * 
     * @param timeout the timeout value to set.
     * @return the ScriptExecutionProperties object itself.
     */
    public ScriptExecutionProperties withTimeout(String timeout) {
        this.timeout = timeout;
        return this;
    }

    /**
     * Get the retention property: Time to live for the resource. If not provided, will be available for 60 days.
     * 
     * @return the retention value.
     */
    public String retention() {
        return this.retention;
    }

    /**
     * Set the retention property: Time to live for the resource. If not provided, will be available for 60 days.
     * 
     * @param retention the retention value to set.
     * @return the ScriptExecutionProperties object itself.
     */
    public ScriptExecutionProperties withRetention(String retention) {
        this.retention = retention;
        return this;
    }

    /**
     * Get the submittedAt property: Time the script execution was submitted.
     * 
     * @return the submittedAt value.
     */
    public OffsetDateTime submittedAt() {
        return this.submittedAt;
    }

    /**
     * Get the startedAt property: Time the script execution was started.
     * 
     * @return the startedAt value.
     */
    public OffsetDateTime startedAt() {
        return this.startedAt;
    }

    /**
     * Get the finishedAt property: Time the script execution was finished.
     * 
     * @return the finishedAt value.
     */
    public OffsetDateTime finishedAt() {
        return this.finishedAt;
    }

    /**
     * Get the provisioningState property: The state of the script execution resource.
     * 
     * @return the provisioningState value.
     */
    public ScriptExecutionProvisioningState provisioningState() {
        return this.provisioningState;
    }

    /**
     * Get the output property: Standard output stream from the powershell execution.
     * 
     * @return the output value.
     */
    public List output() {
        return this.output;
    }

    /**
     * Set the output property: Standard output stream from the powershell execution.
     * 
     * @param output the output value to set.
     * @return the ScriptExecutionProperties object itself.
     */
    public ScriptExecutionProperties withOutput(List output) {
        this.output = output;
        return this;
    }

    /**
     * Get the namedOutputs property: User-defined dictionary.
     * 
     * @return the namedOutputs value.
     */
    public Map namedOutputs() {
        return this.namedOutputs;
    }

    /**
     * Set the namedOutputs property: User-defined dictionary.
     * 
     * @param namedOutputs the namedOutputs value to set.
     * @return the ScriptExecutionProperties object itself.
     */
    public ScriptExecutionProperties withNamedOutputs(Map namedOutputs) {
        this.namedOutputs = namedOutputs;
        return this;
    }

    /**
     * Get the information property: Standard information out stream from the powershell execution.
     * 
     * @return the information value.
     */
    public List information() {
        return this.information;
    }

    /**
     * Get the warnings property: Standard warning out stream from the powershell execution.
     * 
     * @return the warnings value.
     */
    public List warnings() {
        return this.warnings;
    }

    /**
     * Get the errors property: Standard error output stream from the powershell execution.
     * 
     * @return the errors value.
     */
    public List errors() {
        return this.errors;
    }

    /**
     * Validates the instance.
     * 
     * @throws IllegalArgumentException thrown if the instance is not valid.
     */
    public void validate() {
        if (parameters() != null) {
            parameters().forEach(e -> e.validate());
        }
        if (hiddenParameters() != null) {
            hiddenParameters().forEach(e -> e.validate());
        }
        if (timeout() == null) {
            throw LOGGER.atError()
                .log(new IllegalArgumentException(
                    "Missing required property timeout in model ScriptExecutionProperties"));
        }
    }

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

    /**
     * {@inheritDoc}
     */
    @Override
    public JsonWriter toJson(JsonWriter jsonWriter) throws IOException {
        jsonWriter.writeStartObject();
        jsonWriter.writeStringField("timeout", this.timeout);
        jsonWriter.writeStringField("scriptCmdletId", this.scriptCmdletId);
        jsonWriter.writeArrayField("parameters", this.parameters, (writer, element) -> writer.writeJson(element));
        jsonWriter.writeArrayField("hiddenParameters", this.hiddenParameters,
            (writer, element) -> writer.writeJson(element));
        jsonWriter.writeStringField("failureReason", this.failureReason);
        jsonWriter.writeStringField("retention", this.retention);
        jsonWriter.writeArrayField("output", this.output, (writer, element) -> writer.writeString(element));
        jsonWriter.writeMapField("namedOutputs", this.namedOutputs, (writer, element) -> writer.writeUntyped(element));
        return jsonWriter.writeEndObject();
    }

    /**
     * Reads an instance of ScriptExecutionProperties from the JsonReader.
     * 
     * @param jsonReader The JsonReader being read.
     * @return An instance of ScriptExecutionProperties 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 ScriptExecutionProperties.
     */
    public static ScriptExecutionProperties fromJson(JsonReader jsonReader) throws IOException {
        return jsonReader.readObject(reader -> {
            ScriptExecutionProperties deserializedScriptExecutionProperties = new ScriptExecutionProperties();
            while (reader.nextToken() != JsonToken.END_OBJECT) {
                String fieldName = reader.getFieldName();
                reader.nextToken();

                if ("timeout".equals(fieldName)) {
                    deserializedScriptExecutionProperties.timeout = reader.getString();
                } else if ("scriptCmdletId".equals(fieldName)) {
                    deserializedScriptExecutionProperties.scriptCmdletId = reader.getString();
                } else if ("parameters".equals(fieldName)) {
                    List parameters
                        = reader.readArray(reader1 -> ScriptExecutionParameter.fromJson(reader1));
                    deserializedScriptExecutionProperties.parameters = parameters;
                } else if ("hiddenParameters".equals(fieldName)) {
                    List hiddenParameters
                        = reader.readArray(reader1 -> ScriptExecutionParameter.fromJson(reader1));
                    deserializedScriptExecutionProperties.hiddenParameters = hiddenParameters;
                } else if ("failureReason".equals(fieldName)) {
                    deserializedScriptExecutionProperties.failureReason = reader.getString();
                } else if ("retention".equals(fieldName)) {
                    deserializedScriptExecutionProperties.retention = reader.getString();
                } else if ("submittedAt".equals(fieldName)) {
                    deserializedScriptExecutionProperties.submittedAt = reader
                        .getNullable(nonNullReader -> CoreUtils.parseBestOffsetDateTime(nonNullReader.getString()));
                } else if ("startedAt".equals(fieldName)) {
                    deserializedScriptExecutionProperties.startedAt = reader
                        .getNullable(nonNullReader -> CoreUtils.parseBestOffsetDateTime(nonNullReader.getString()));
                } else if ("finishedAt".equals(fieldName)) {
                    deserializedScriptExecutionProperties.finishedAt = reader
                        .getNullable(nonNullReader -> CoreUtils.parseBestOffsetDateTime(nonNullReader.getString()));
                } else if ("provisioningState".equals(fieldName)) {
                    deserializedScriptExecutionProperties.provisioningState
                        = ScriptExecutionProvisioningState.fromString(reader.getString());
                } else if ("output".equals(fieldName)) {
                    List output = reader.readArray(reader1 -> reader1.getString());
                    deserializedScriptExecutionProperties.output = output;
                } else if ("namedOutputs".equals(fieldName)) {
                    Map namedOutputs = reader.readMap(reader1 -> reader1.readUntyped());
                    deserializedScriptExecutionProperties.namedOutputs = namedOutputs;
                } else if ("information".equals(fieldName)) {
                    List information = reader.readArray(reader1 -> reader1.getString());
                    deserializedScriptExecutionProperties.information = information;
                } else if ("warnings".equals(fieldName)) {
                    List warnings = reader.readArray(reader1 -> reader1.getString());
                    deserializedScriptExecutionProperties.warnings = warnings;
                } else if ("errors".equals(fieldName)) {
                    List errors = reader.readArray(reader1 -> reader1.getString());
                    deserializedScriptExecutionProperties.errors = errors;
                } else {
                    reader.skipChildren();
                }
            }

            return deserializedScriptExecutionProperties;
        });
    }
}




© 2015 - 2025 Weber Informatics LLC | Privacy Policy