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

com.azure.resourcemanager.resourcehealth.models.AvailabilityStatusPropertiesRecentlyResolved Maven / Gradle / Ivy

// Copyright (c) Microsoft Corporation. All rights reserved.
// Licensed under the MIT License.
// Code generated by Microsoft (R) AutoRest Code Generator.

package com.azure.resourcemanager.resourcehealth.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.time.format.DateTimeFormatter;

/**
 * An annotation describing a change in the availabilityState to Available from Unavailable with a reasonType of type
 * Unplanned.
 */
@Fluent
public final class AvailabilityStatusPropertiesRecentlyResolved
    implements JsonSerializable {
    /*
     * Timestamp for when the availabilityState changed to Unavailable
     */
    private OffsetDateTime unavailableOccuredTime;

    /*
     * Timestamp when the availabilityState changes to Available.
     */
    private OffsetDateTime resolvedTime;

    /*
     * Brief description of cause of the resource becoming unavailable.
     */
    private String unavailableSummary;

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

    /**
     * Get the unavailableOccuredTime property: Timestamp for when the availabilityState changed to Unavailable.
     * 
     * @return the unavailableOccuredTime value.
     */
    public OffsetDateTime unavailableOccuredTime() {
        return this.unavailableOccuredTime;
    }

    /**
     * Set the unavailableOccuredTime property: Timestamp for when the availabilityState changed to Unavailable.
     * 
     * @param unavailableOccuredTime the unavailableOccuredTime value to set.
     * @return the AvailabilityStatusPropertiesRecentlyResolved object itself.
     */
    public AvailabilityStatusPropertiesRecentlyResolved
        withUnavailableOccuredTime(OffsetDateTime unavailableOccuredTime) {
        this.unavailableOccuredTime = unavailableOccuredTime;
        return this;
    }

    /**
     * Get the resolvedTime property: Timestamp when the availabilityState changes to Available.
     * 
     * @return the resolvedTime value.
     */
    public OffsetDateTime resolvedTime() {
        return this.resolvedTime;
    }

    /**
     * Set the resolvedTime property: Timestamp when the availabilityState changes to Available.
     * 
     * @param resolvedTime the resolvedTime value to set.
     * @return the AvailabilityStatusPropertiesRecentlyResolved object itself.
     */
    public AvailabilityStatusPropertiesRecentlyResolved withResolvedTime(OffsetDateTime resolvedTime) {
        this.resolvedTime = resolvedTime;
        return this;
    }

    /**
     * Get the unavailableSummary property: Brief description of cause of the resource becoming unavailable.
     * 
     * @return the unavailableSummary value.
     */
    public String unavailableSummary() {
        return this.unavailableSummary;
    }

    /**
     * Set the unavailableSummary property: Brief description of cause of the resource becoming unavailable.
     * 
     * @param unavailableSummary the unavailableSummary value to set.
     * @return the AvailabilityStatusPropertiesRecentlyResolved object itself.
     */
    public AvailabilityStatusPropertiesRecentlyResolved withUnavailableSummary(String unavailableSummary) {
        this.unavailableSummary = unavailableSummary;
        return this;
    }

    /**
     * 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("unavailableOccuredTime",
            this.unavailableOccuredTime == null
                ? null
                : DateTimeFormatter.ISO_OFFSET_DATE_TIME.format(this.unavailableOccuredTime));
        jsonWriter.writeStringField("resolvedTime",
            this.resolvedTime == null ? null : DateTimeFormatter.ISO_OFFSET_DATE_TIME.format(this.resolvedTime));
        jsonWriter.writeStringField("unavailableSummary", this.unavailableSummary);
        return jsonWriter.writeEndObject();
    }

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

                if ("unavailableOccuredTime".equals(fieldName)) {
                    deserializedAvailabilityStatusPropertiesRecentlyResolved.unavailableOccuredTime = reader
                        .getNullable(nonNullReader -> CoreUtils.parseBestOffsetDateTime(nonNullReader.getString()));
                } else if ("resolvedTime".equals(fieldName)) {
                    deserializedAvailabilityStatusPropertiesRecentlyResolved.resolvedTime = reader
                        .getNullable(nonNullReader -> CoreUtils.parseBestOffsetDateTime(nonNullReader.getString()));
                } else if ("unavailableSummary".equals(fieldName)) {
                    deserializedAvailabilityStatusPropertiesRecentlyResolved.unavailableSummary = reader.getString();
                } else {
                    reader.skipChildren();
                }
            }

            return deserializedAvailabilityStatusPropertiesRecentlyResolved;
        });
    }
}




© 2015 - 2025 Weber Informatics LLC | Privacy Policy