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

com.azure.resourcemanager.azurestackhci.fluent.models.UpdateRunProperties Maven / Gradle / Ivy

Go to download

This package contains Microsoft Azure SDK for AzureStackHci Management SDK. For documentation on how to use this package, please see https://aka.ms/azsdk/java/mgmt. Azure Stack HCI management service. Package tag package-2024-04.

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.azurestackhci.fluent.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 com.azure.resourcemanager.azurestackhci.models.ProvisioningState;
import com.azure.resourcemanager.azurestackhci.models.UpdateRunPropertiesState;
import java.io.IOException;
import java.time.OffsetDateTime;
import java.time.format.DateTimeFormatter;
import java.util.List;

/**
 * Details of an Update run.
 */
@Fluent
public final class UpdateRunProperties implements JsonSerializable {
    /*
     * Provisioning state of the UpdateRuns proxy resource.
     */
    private ProvisioningState provisioningState;

    /*
     * Timestamp of the update run was started.
     */
    private OffsetDateTime timeStarted;

    /*
     * Timestamp of the most recently completed step in the update run.
     */
    private OffsetDateTime lastUpdatedTime;

    /*
     * Duration of the update run.
     */
    private String duration;

    /*
     * State of the update run.
     */
    private UpdateRunPropertiesState state;

    /*
     * Progress representation of the update run steps.
     */
    private Step innerProgress;

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

    /**
     * Get the provisioningState property: Provisioning state of the UpdateRuns proxy resource.
     * 
     * @return the provisioningState value.
     */
    public ProvisioningState provisioningState() {
        return this.provisioningState;
    }

    /**
     * Get the timeStarted property: Timestamp of the update run was started.
     * 
     * @return the timeStarted value.
     */
    public OffsetDateTime timeStarted() {
        return this.timeStarted;
    }

    /**
     * Set the timeStarted property: Timestamp of the update run was started.
     * 
     * @param timeStarted the timeStarted value to set.
     * @return the UpdateRunProperties object itself.
     */
    public UpdateRunProperties withTimeStarted(OffsetDateTime timeStarted) {
        this.timeStarted = timeStarted;
        return this;
    }

    /**
     * Get the lastUpdatedTime property: Timestamp of the most recently completed step in the update run.
     * 
     * @return the lastUpdatedTime value.
     */
    public OffsetDateTime lastUpdatedTime() {
        return this.lastUpdatedTime;
    }

    /**
     * Set the lastUpdatedTime property: Timestamp of the most recently completed step in the update run.
     * 
     * @param lastUpdatedTime the lastUpdatedTime value to set.
     * @return the UpdateRunProperties object itself.
     */
    public UpdateRunProperties withLastUpdatedTime(OffsetDateTime lastUpdatedTime) {
        this.lastUpdatedTime = lastUpdatedTime;
        return this;
    }

    /**
     * Get the duration property: Duration of the update run.
     * 
     * @return the duration value.
     */
    public String duration() {
        return this.duration;
    }

    /**
     * Set the duration property: Duration of the update run.
     * 
     * @param duration the duration value to set.
     * @return the UpdateRunProperties object itself.
     */
    public UpdateRunProperties withDuration(String duration) {
        this.duration = duration;
        return this;
    }

    /**
     * Get the state property: State of the update run.
     * 
     * @return the state value.
     */
    public UpdateRunPropertiesState state() {
        return this.state;
    }

    /**
     * Set the state property: State of the update run.
     * 
     * @param state the state value to set.
     * @return the UpdateRunProperties object itself.
     */
    public UpdateRunProperties withState(UpdateRunPropertiesState state) {
        this.state = state;
        return this;
    }

    /**
     * Get the innerProgress property: Progress representation of the update run steps.
     * 
     * @return the innerProgress value.
     */
    private Step innerProgress() {
        return this.innerProgress;
    }

    /**
     * Get the name property: Name of the step.
     * 
     * @return the name value.
     */
    public String name() {
        return this.innerProgress() == null ? null : this.innerProgress().name();
    }

    /**
     * Set the name property: Name of the step.
     * 
     * @param name the name value to set.
     * @return the UpdateRunProperties object itself.
     */
    public UpdateRunProperties withName(String name) {
        if (this.innerProgress() == null) {
            this.innerProgress = new Step();
        }
        this.innerProgress().withName(name);
        return this;
    }

    /**
     * Get the description property: More detailed description of the step.
     * 
     * @return the description value.
     */
    public String description() {
        return this.innerProgress() == null ? null : this.innerProgress().description();
    }

    /**
     * Set the description property: More detailed description of the step.
     * 
     * @param description the description value to set.
     * @return the UpdateRunProperties object itself.
     */
    public UpdateRunProperties withDescription(String description) {
        if (this.innerProgress() == null) {
            this.innerProgress = new Step();
        }
        this.innerProgress().withDescription(description);
        return this;
    }

    /**
     * Get the errorMessage property: Error message, specified if the step is in a failed state.
     * 
     * @return the errorMessage value.
     */
    public String errorMessage() {
        return this.innerProgress() == null ? null : this.innerProgress().errorMessage();
    }

    /**
     * Set the errorMessage property: Error message, specified if the step is in a failed state.
     * 
     * @param errorMessage the errorMessage value to set.
     * @return the UpdateRunProperties object itself.
     */
    public UpdateRunProperties withErrorMessage(String errorMessage) {
        if (this.innerProgress() == null) {
            this.innerProgress = new Step();
        }
        this.innerProgress().withErrorMessage(errorMessage);
        return this;
    }

    /**
     * Get the status property: Status of the step, bubbled up from the ECE action plan for installation attempts.
     * Values are: 'Success', 'Error', 'InProgress', and 'Unknown status'.
     * 
     * @return the status value.
     */
    public String status() {
        return this.innerProgress() == null ? null : this.innerProgress().status();
    }

    /**
     * Set the status property: Status of the step, bubbled up from the ECE action plan for installation attempts.
     * Values are: 'Success', 'Error', 'InProgress', and 'Unknown status'.
     * 
     * @param status the status value to set.
     * @return the UpdateRunProperties object itself.
     */
    public UpdateRunProperties withStatus(String status) {
        if (this.innerProgress() == null) {
            this.innerProgress = new Step();
        }
        this.innerProgress().withStatus(status);
        return this;
    }

    /**
     * Get the startTimeUtc property: When the step started, or empty if it has not started executing.
     * 
     * @return the startTimeUtc value.
     */
    public OffsetDateTime startTimeUtc() {
        return this.innerProgress() == null ? null : this.innerProgress().startTimeUtc();
    }

    /**
     * Set the startTimeUtc property: When the step started, or empty if it has not started executing.
     * 
     * @param startTimeUtc the startTimeUtc value to set.
     * @return the UpdateRunProperties object itself.
     */
    public UpdateRunProperties withStartTimeUtc(OffsetDateTime startTimeUtc) {
        if (this.innerProgress() == null) {
            this.innerProgress = new Step();
        }
        this.innerProgress().withStartTimeUtc(startTimeUtc);
        return this;
    }

    /**
     * Get the endTimeUtc property: When the step reached a terminal state.
     * 
     * @return the endTimeUtc value.
     */
    public OffsetDateTime endTimeUtc() {
        return this.innerProgress() == null ? null : this.innerProgress().endTimeUtc();
    }

    /**
     * Set the endTimeUtc property: When the step reached a terminal state.
     * 
     * @param endTimeUtc the endTimeUtc value to set.
     * @return the UpdateRunProperties object itself.
     */
    public UpdateRunProperties withEndTimeUtc(OffsetDateTime endTimeUtc) {
        if (this.innerProgress() == null) {
            this.innerProgress = new Step();
        }
        this.innerProgress().withEndTimeUtc(endTimeUtc);
        return this;
    }

    /**
     * Get the lastUpdatedTimeUtc property: Completion time of this step or the last completed sub-step.
     * 
     * @return the lastUpdatedTimeUtc value.
     */
    public OffsetDateTime lastUpdatedTimeUtc() {
        return this.innerProgress() == null ? null : this.innerProgress().lastUpdatedTimeUtc();
    }

    /**
     * Set the lastUpdatedTimeUtc property: Completion time of this step or the last completed sub-step.
     * 
     * @param lastUpdatedTimeUtc the lastUpdatedTimeUtc value to set.
     * @return the UpdateRunProperties object itself.
     */
    public UpdateRunProperties withLastUpdatedTimeUtc(OffsetDateTime lastUpdatedTimeUtc) {
        if (this.innerProgress() == null) {
            this.innerProgress = new Step();
        }
        this.innerProgress().withLastUpdatedTimeUtc(lastUpdatedTimeUtc);
        return this;
    }

    /**
     * Get the expectedExecutionTime property: Expected execution time of a given step. This is optionally authored in
     * the update action plan and can be empty.
     * 
     * @return the expectedExecutionTime value.
     */
    public String expectedExecutionTime() {
        return this.innerProgress() == null ? null : this.innerProgress().expectedExecutionTime();
    }

    /**
     * Set the expectedExecutionTime property: Expected execution time of a given step. This is optionally authored in
     * the update action plan and can be empty.
     * 
     * @param expectedExecutionTime the expectedExecutionTime value to set.
     * @return the UpdateRunProperties object itself.
     */
    public UpdateRunProperties withExpectedExecutionTime(String expectedExecutionTime) {
        if (this.innerProgress() == null) {
            this.innerProgress = new Step();
        }
        this.innerProgress().withExpectedExecutionTime(expectedExecutionTime);
        return this;
    }

    /**
     * Get the steps property: Recursive model for child steps of this step.
     * 
     * @return the steps value.
     */
    public List steps() {
        return this.innerProgress() == null ? null : this.innerProgress().steps();
    }

    /**
     * Set the steps property: Recursive model for child steps of this step.
     * 
     * @param steps the steps value to set.
     * @return the UpdateRunProperties object itself.
     */
    public UpdateRunProperties withSteps(List steps) {
        if (this.innerProgress() == null) {
            this.innerProgress = new Step();
        }
        this.innerProgress().withSteps(steps);
        return this;
    }

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

    /**
     * {@inheritDoc}
     */
    @Override
    public JsonWriter toJson(JsonWriter jsonWriter) throws IOException {
        jsonWriter.writeStartObject();
        jsonWriter.writeStringField("timeStarted",
            this.timeStarted == null ? null : DateTimeFormatter.ISO_OFFSET_DATE_TIME.format(this.timeStarted));
        jsonWriter.writeStringField("lastUpdatedTime",
            this.lastUpdatedTime == null ? null : DateTimeFormatter.ISO_OFFSET_DATE_TIME.format(this.lastUpdatedTime));
        jsonWriter.writeStringField("duration", this.duration);
        jsonWriter.writeStringField("state", this.state == null ? null : this.state.toString());
        jsonWriter.writeJsonField("progress", this.innerProgress);
        return jsonWriter.writeEndObject();
    }

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

                if ("provisioningState".equals(fieldName)) {
                    deserializedUpdateRunProperties.provisioningState
                        = ProvisioningState.fromString(reader.getString());
                } else if ("timeStarted".equals(fieldName)) {
                    deserializedUpdateRunProperties.timeStarted = reader
                        .getNullable(nonNullReader -> CoreUtils.parseBestOffsetDateTime(nonNullReader.getString()));
                } else if ("lastUpdatedTime".equals(fieldName)) {
                    deserializedUpdateRunProperties.lastUpdatedTime = reader
                        .getNullable(nonNullReader -> CoreUtils.parseBestOffsetDateTime(nonNullReader.getString()));
                } else if ("duration".equals(fieldName)) {
                    deserializedUpdateRunProperties.duration = reader.getString();
                } else if ("state".equals(fieldName)) {
                    deserializedUpdateRunProperties.state = UpdateRunPropertiesState.fromString(reader.getString());
                } else if ("progress".equals(fieldName)) {
                    deserializedUpdateRunProperties.innerProgress = Step.fromJson(reader);
                } else {
                    reader.skipChildren();
                }
            }

            return deserializedUpdateRunProperties;
        });
    }
}




© 2015 - 2024 Weber Informatics LLC | Privacy Policy