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

com.azure.resourcemanager.storagecache.models.CacheHealth Maven / Gradle / Ivy

Go to download

This package contains Microsoft Azure SDK for StorageCache Management SDK. For documentation on how to use this package, please see https://aka.ms/azsdk/java/mgmt. Azure Managed Lustre provides a fully managed Lustre® file system, integrated with Blob storage, for use on demand. These operations create and manage Azure Managed Lustre file systems. Package tag package-2024-03.

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

import com.azure.core.annotation.Fluent;
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.util.List;

/**
 * An indication of cache health. Gives more information about health than just that related to provisioning.
 */
@Fluent
public final class CacheHealth implements JsonSerializable {
    /*
     * List of cache health states. Down is when the cluster is not responding. Degraded is when its functioning but has
     * some alerts. Transitioning when it is creating or deleting. Unknown will be returned in old api versions when a
     * new value is added in future versions. WaitingForKey is when the create is waiting for the system assigned
     * identity to be given access to the encryption key in the encryption settings.
     */
    private HealthStateType state;

    /*
     * Describes explanation of state.
     */
    private String statusDescription;

    /*
     * Outstanding conditions that need to be investigated and resolved.
     */
    private List conditions;

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

    /**
     * Get the state property: List of cache health states. Down is when the cluster is not responding. Degraded is when
     * its functioning but has some alerts. Transitioning when it is creating or deleting. Unknown will be returned in
     * old api versions when a new value is added in future versions. WaitingForKey is when the create is waiting for
     * the system assigned identity to be given access to the encryption key in the encryption settings.
     * 
     * @return the state value.
     */
    public HealthStateType state() {
        return this.state;
    }

    /**
     * Set the state property: List of cache health states. Down is when the cluster is not responding. Degraded is when
     * its functioning but has some alerts. Transitioning when it is creating or deleting. Unknown will be returned in
     * old api versions when a new value is added in future versions. WaitingForKey is when the create is waiting for
     * the system assigned identity to be given access to the encryption key in the encryption settings.
     * 
     * @param state the state value to set.
     * @return the CacheHealth object itself.
     */
    public CacheHealth withState(HealthStateType state) {
        this.state = state;
        return this;
    }

    /**
     * Get the statusDescription property: Describes explanation of state.
     * 
     * @return the statusDescription value.
     */
    public String statusDescription() {
        return this.statusDescription;
    }

    /**
     * Set the statusDescription property: Describes explanation of state.
     * 
     * @param statusDescription the statusDescription value to set.
     * @return the CacheHealth object itself.
     */
    public CacheHealth withStatusDescription(String statusDescription) {
        this.statusDescription = statusDescription;
        return this;
    }

    /**
     * Get the conditions property: Outstanding conditions that need to be investigated and resolved.
     * 
     * @return the conditions value.
     */
    public List conditions() {
        return this.conditions;
    }

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

    /**
     * {@inheritDoc}
     */
    @Override
    public JsonWriter toJson(JsonWriter jsonWriter) throws IOException {
        jsonWriter.writeStartObject();
        jsonWriter.writeStringField("state", this.state == null ? null : this.state.toString());
        jsonWriter.writeStringField("statusDescription", this.statusDescription);
        return jsonWriter.writeEndObject();
    }

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

                if ("state".equals(fieldName)) {
                    deserializedCacheHealth.state = HealthStateType.fromString(reader.getString());
                } else if ("statusDescription".equals(fieldName)) {
                    deserializedCacheHealth.statusDescription = reader.getString();
                } else if ("conditions".equals(fieldName)) {
                    List conditions = reader.readArray(reader1 -> Condition.fromJson(reader1));
                    deserializedCacheHealth.conditions = conditions;
                } else {
                    reader.skipChildren();
                }
            }

            return deserializedCacheHealth;
        });
    }
}




© 2015 - 2025 Weber Informatics LLC | Privacy Policy