// 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.fasterxml.jackson.annotation.JsonProperty;
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 {
    /*
     * 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.
     */
    @JsonProperty(value = "state")
    private HealthStateType state;

    /*
     * Describes explanation of state.
     */
    @JsonProperty(value = "statusDescription")
    private String statusDescription;

    /*
     * Outstanding conditions that need to be investigated and resolved.
     */
    @JsonProperty(value = "conditions", access = JsonProperty.Access.WRITE_ONLY)
    private List<Condition> 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<Condition> 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());
        }
    }
}
