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

com.azure.resourcemanager.hybridcompute.models.AgentUpgrade Maven / Gradle / Ivy

Go to download

This package contains Microsoft Azure SDK for HybridCompute Management SDK. For documentation on how to use this package, please see https://aka.ms/azsdk/java/mgmt. The Hybrid Compute Management Client. Package tag package-preview-2024-05.

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

import com.azure.core.annotation.Fluent;
import com.azure.core.util.CoreUtils;
import com.azure.json.JsonReader;
import com.azure.json.JsonSerializable;
import com.azure.json.JsonToken;
import com.azure.json.JsonWriter;
import java.io.IOException;
import java.time.OffsetDateTime;
import java.util.Objects;
import java.util.UUID;

/**
 * The info w.r.t Agent Upgrade.
 */
@Fluent
public final class AgentUpgrade implements JsonSerializable {
    /*
     * Specifies the version info w.r.t AgentUpgrade for the machine.
     */
    private String desiredVersion;

    /*
     * The correlation ID passed in from RSM per upgrade.
     */
    private UUID correlationId;

    /*
     * Specifies if RSM should try to upgrade this machine
     */
    private Boolean enableAutomaticUpgrade;

    /*
     * Specifies the version of the last attempt
     */
    private String lastAttemptDesiredVersion;

    /*
     * Timestamp of last upgrade attempt
     */
    private OffsetDateTime lastAttemptTimestamp;

    /*
     * Specifies the status of Agent Upgrade.
     */
    private LastAttemptStatusEnum lastAttemptStatus;

    /*
     * Failure message of last upgrade attempt if any.
     */
    private String lastAttemptMessage;

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

    /**
     * Get the desiredVersion property: Specifies the version info w.r.t AgentUpgrade for the machine.
     * 
     * @return the desiredVersion value.
     */
    public String desiredVersion() {
        return this.desiredVersion;
    }

    /**
     * Set the desiredVersion property: Specifies the version info w.r.t AgentUpgrade for the machine.
     * 
     * @param desiredVersion the desiredVersion value to set.
     * @return the AgentUpgrade object itself.
     */
    public AgentUpgrade withDesiredVersion(String desiredVersion) {
        this.desiredVersion = desiredVersion;
        return this;
    }

    /**
     * Get the correlationId property: The correlation ID passed in from RSM per upgrade.
     * 
     * @return the correlationId value.
     */
    public UUID correlationId() {
        return this.correlationId;
    }

    /**
     * Set the correlationId property: The correlation ID passed in from RSM per upgrade.
     * 
     * @param correlationId the correlationId value to set.
     * @return the AgentUpgrade object itself.
     */
    public AgentUpgrade withCorrelationId(UUID correlationId) {
        this.correlationId = correlationId;
        return this;
    }

    /**
     * Get the enableAutomaticUpgrade property: Specifies if RSM should try to upgrade this machine.
     * 
     * @return the enableAutomaticUpgrade value.
     */
    public Boolean enableAutomaticUpgrade() {
        return this.enableAutomaticUpgrade;
    }

    /**
     * Set the enableAutomaticUpgrade property: Specifies if RSM should try to upgrade this machine.
     * 
     * @param enableAutomaticUpgrade the enableAutomaticUpgrade value to set.
     * @return the AgentUpgrade object itself.
     */
    public AgentUpgrade withEnableAutomaticUpgrade(Boolean enableAutomaticUpgrade) {
        this.enableAutomaticUpgrade = enableAutomaticUpgrade;
        return this;
    }

    /**
     * Get the lastAttemptDesiredVersion property: Specifies the version of the last attempt.
     * 
     * @return the lastAttemptDesiredVersion value.
     */
    public String lastAttemptDesiredVersion() {
        return this.lastAttemptDesiredVersion;
    }

    /**
     * Get the lastAttemptTimestamp property: Timestamp of last upgrade attempt.
     * 
     * @return the lastAttemptTimestamp value.
     */
    public OffsetDateTime lastAttemptTimestamp() {
        return this.lastAttemptTimestamp;
    }

    /**
     * Get the lastAttemptStatus property: Specifies the status of Agent Upgrade.
     * 
     * @return the lastAttemptStatus value.
     */
    public LastAttemptStatusEnum lastAttemptStatus() {
        return this.lastAttemptStatus;
    }

    /**
     * Get the lastAttemptMessage property: Failure message of last upgrade attempt if any.
     * 
     * @return the lastAttemptMessage value.
     */
    public String lastAttemptMessage() {
        return this.lastAttemptMessage;
    }

    /**
     * Validates the instance.
     * 
     * @throws IllegalArgumentException thrown if the instance is not valid.
     */
    public void validate() {
    }

    /**
     * {@inheritDoc}
     */
    @Override
    public JsonWriter toJson(JsonWriter jsonWriter) throws IOException {
        jsonWriter.writeStartObject();
        jsonWriter.writeStringField("desiredVersion", this.desiredVersion);
        jsonWriter.writeStringField("correlationId", Objects.toString(this.correlationId, null));
        jsonWriter.writeBooleanField("enableAutomaticUpgrade", this.enableAutomaticUpgrade);
        return jsonWriter.writeEndObject();
    }

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

                if ("desiredVersion".equals(fieldName)) {
                    deserializedAgentUpgrade.desiredVersion = reader.getString();
                } else if ("correlationId".equals(fieldName)) {
                    deserializedAgentUpgrade.correlationId
                        = reader.getNullable(nonNullReader -> UUID.fromString(nonNullReader.getString()));
                } else if ("enableAutomaticUpgrade".equals(fieldName)) {
                    deserializedAgentUpgrade.enableAutomaticUpgrade = reader.getNullable(JsonReader::getBoolean);
                } else if ("lastAttemptDesiredVersion".equals(fieldName)) {
                    deserializedAgentUpgrade.lastAttemptDesiredVersion = reader.getString();
                } else if ("lastAttemptTimestamp".equals(fieldName)) {
                    deserializedAgentUpgrade.lastAttemptTimestamp = reader
                        .getNullable(nonNullReader -> CoreUtils.parseBestOffsetDateTime(nonNullReader.getString()));
                } else if ("lastAttemptStatus".equals(fieldName)) {
                    deserializedAgentUpgrade.lastAttemptStatus = LastAttemptStatusEnum.fromString(reader.getString());
                } else if ("lastAttemptMessage".equals(fieldName)) {
                    deserializedAgentUpgrade.lastAttemptMessage = reader.getString();
                } else {
                    reader.skipChildren();
                }
            }

            return deserializedAgentUpgrade;
        });
    }
}




© 2015 - 2024 Weber Informatics LLC | Privacy Policy