// 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.fasterxml.jackson.annotation.JsonProperty;
import java.time.OffsetDateTime;
import java.util.List;

/** Properties of availability state. */
@Fluent
public final class AvailabilityStatusProperties {
    /*
     * Availability status of the resource. When it is null, this availabilityStatus object represents an availability
     * impacting event
     */
    @JsonProperty(value = "availabilityState")
    private AvailabilityStateValues availabilityState;

    /*
     * Title description of the availability status.
     */
    @JsonProperty(value = "title")
    private String title;

    /*
     * Summary description of the availability status.
     */
    @JsonProperty(value = "summary")
    private String summary;

    /*
     * Details of the availability status.
     */
    @JsonProperty(value = "detailedStatus")
    private String detailedStatus;

    /*
     * When the resource's availabilityState is Unavailable, it describes where the health impacting event was
     * originated. Examples are planned, unplanned, user initiated or an outage etc.
     */
    @JsonProperty(value = "reasonType")
    private String reasonType;

    /*
     * When an event is created, it can either be triggered by a customer or the platform of the resource and this
     * field will illustrate that. This field is connected to the category field in this object.
     */
    @JsonProperty(value = "context")
    private String context;

    /*
     * When a context field is set to Platform, this field will reflect if the event was planned or unplanned. If the
     * context field does not have a value of Platform, then this field will be ignored.
     */
    @JsonProperty(value = "category")
    private String category;

    /*
     * The Article Id
     */
    @JsonProperty(value = "articleId")
    private String articleId;

    /*
     * When the resource's availabilityState is Unavailable, it provides the Timestamp for when the health impacting
     * event was received.
     */
    @JsonProperty(value = "rootCauseAttributionTime")
    private OffsetDateTime rootCauseAttributionTime;

    /*
     * In case of an availability impacting event, it describes when the health impacting event was originated.
     * Examples are Lifecycle, Downtime, Fault Analysis etc.
     */
    @JsonProperty(value = "healthEventType")
    private String healthEventType;

    /*
     * In case of an availability impacting event, it describes where the health impacting event was originated.
     * Examples are PlatformInitiated, UserInitiated etc.
     */
    @JsonProperty(value = "healthEventCause")
    private String healthEventCause;

    /*
     * In case of an availability impacting event, it describes the category of a PlatformInitiated health impacting
     * event. Examples are Planned, Unplanned etc.
     */
    @JsonProperty(value = "healthEventCategory")
    private String healthEventCategory;

    /*
     * It is a unique Id that identifies the event
     */
    @JsonProperty(value = "healthEventId")
    private String healthEventId;

    /*
     * When the resource's availabilityState is Unavailable and the reasonType is not User Initiated, it provides the
     * date and time for when the issue is expected to be resolved.
     */
    @JsonProperty(value = "resolutionETA")
    private OffsetDateTime resolutionEta;

    /*
     * Timestamp for when last change in health status occurred.
     */
    @JsonProperty(value = "occuredTime")
    private OffsetDateTime occuredTime;

    /*
     * Chronicity of the availability transition.
     */
    @JsonProperty(value = "reasonChronicity")
    private ReasonChronicityTypes reasonChronicity;

    /*
     * Timestamp for when the health was last checked.
     */
    @JsonProperty(value = "reportedTime")
    private OffsetDateTime reportedTime;

    /*
     * An annotation describing a change in the availabilityState to Available from Unavailable with a reasonType of
     * type Unplanned
     */
    @JsonProperty(value = "recentlyResolved")
    private AvailabilityStatusPropertiesRecentlyResolved recentlyResolved;

    /*
     * Lists actions the user can take based on the current availabilityState of the resource.
     */
    @JsonProperty(value = "recommendedActions")
    private List<RecommendedAction> recommendedActions;

    /*
     * Lists the service impacting events that may be affecting the health of the resource.
     */
    @JsonProperty(value = "serviceImpactingEvents")
    private List<ServiceImpactingEvent> serviceImpactingEvents;

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

    /**
     * Get the availabilityState property: Availability status of the resource. When it is null, this availabilityStatus
     * object represents an availability impacting event.
     *
     * @return the availabilityState value.
     */
    public AvailabilityStateValues availabilityState() {
        return this.availabilityState;
    }

    /**
     * Set the availabilityState property: Availability status of the resource. When it is null, this availabilityStatus
     * object represents an availability impacting event.
     *
     * @param availabilityState the availabilityState value to set.
     * @return the AvailabilityStatusProperties object itself.
     */
    public AvailabilityStatusProperties withAvailabilityState(AvailabilityStateValues availabilityState) {
        this.availabilityState = availabilityState;
        return this;
    }

    /**
     * Get the title property: Title description of the availability status.
     *
     * @return the title value.
     */
    public String title() {
        return this.title;
    }

    /**
     * Set the title property: Title description of the availability status.
     *
     * @param title the title value to set.
     * @return the AvailabilityStatusProperties object itself.
     */
    public AvailabilityStatusProperties withTitle(String title) {
        this.title = title;
        return this;
    }

    /**
     * Get the summary property: Summary description of the availability status.
     *
     * @return the summary value.
     */
    public String summary() {
        return this.summary;
    }

    /**
     * Set the summary property: Summary description of the availability status.
     *
     * @param summary the summary value to set.
     * @return the AvailabilityStatusProperties object itself.
     */
    public AvailabilityStatusProperties withSummary(String summary) {
        this.summary = summary;
        return this;
    }

    /**
     * Get the detailedStatus property: Details of the availability status.
     *
     * @return the detailedStatus value.
     */
    public String detailedStatus() {
        return this.detailedStatus;
    }

    /**
     * Set the detailedStatus property: Details of the availability status.
     *
     * @param detailedStatus the detailedStatus value to set.
     * @return the AvailabilityStatusProperties object itself.
     */
    public AvailabilityStatusProperties withDetailedStatus(String detailedStatus) {
        this.detailedStatus = detailedStatus;
        return this;
    }

    /**
     * Get the reasonType property: When the resource's availabilityState is Unavailable, it describes where the health
     * impacting event was originated. Examples are planned, unplanned, user initiated or an outage etc.
     *
     * @return the reasonType value.
     */
    public String reasonType() {
        return this.reasonType;
    }

    /**
     * Set the reasonType property: When the resource's availabilityState is Unavailable, it describes where the health
     * impacting event was originated. Examples are planned, unplanned, user initiated or an outage etc.
     *
     * @param reasonType the reasonType value to set.
     * @return the AvailabilityStatusProperties object itself.
     */
    public AvailabilityStatusProperties withReasonType(String reasonType) {
        this.reasonType = reasonType;
        return this;
    }

    /**
     * Get the context property: When an event is created, it can either be triggered by a customer or the platform of
     * the resource and this field will illustrate that. This field is connected to the category field in this object.
     *
     * @return the context value.
     */
    public String context() {
        return this.context;
    }

    /**
     * Set the context property: When an event is created, it can either be triggered by a customer or the platform of
     * the resource and this field will illustrate that. This field is connected to the category field in this object.
     *
     * @param context the context value to set.
     * @return the AvailabilityStatusProperties object itself.
     */
    public AvailabilityStatusProperties withContext(String context) {
        this.context = context;
        return this;
    }

    /**
     * Get the category property: When a context field is set to Platform, this field will reflect if the event was
     * planned or unplanned. If the context field does not have a value of Platform, then this field will be ignored.
     *
     * @return the category value.
     */
    public String category() {
        return this.category;
    }

    /**
     * Set the category property: When a context field is set to Platform, this field will reflect if the event was
     * planned or unplanned. If the context field does not have a value of Platform, then this field will be ignored.
     *
     * @param category the category value to set.
     * @return the AvailabilityStatusProperties object itself.
     */
    public AvailabilityStatusProperties withCategory(String category) {
        this.category = category;
        return this;
    }

    /**
     * Get the articleId property: The Article Id.
     *
     * @return the articleId value.
     */
    public String articleId() {
        return this.articleId;
    }

    /**
     * Set the articleId property: The Article Id.
     *
     * @param articleId the articleId value to set.
     * @return the AvailabilityStatusProperties object itself.
     */
    public AvailabilityStatusProperties withArticleId(String articleId) {
        this.articleId = articleId;
        return this;
    }

    /**
     * Get the rootCauseAttributionTime property: When the resource's availabilityState is Unavailable, it provides the
     * Timestamp for when the health impacting event was received.
     *
     * @return the rootCauseAttributionTime value.
     */
    public OffsetDateTime rootCauseAttributionTime() {
        return this.rootCauseAttributionTime;
    }

    /**
     * Set the rootCauseAttributionTime property: When the resource's availabilityState is Unavailable, it provides the
     * Timestamp for when the health impacting event was received.
     *
     * @param rootCauseAttributionTime the rootCauseAttributionTime value to set.
     * @return the AvailabilityStatusProperties object itself.
     */
    public AvailabilityStatusProperties withRootCauseAttributionTime(OffsetDateTime rootCauseAttributionTime) {
        this.rootCauseAttributionTime = rootCauseAttributionTime;
        return this;
    }

    /**
     * Get the healthEventType property: In case of an availability impacting event, it describes when the health
     * impacting event was originated. Examples are Lifecycle, Downtime, Fault Analysis etc.
     *
     * @return the healthEventType value.
     */
    public String healthEventType() {
        return this.healthEventType;
    }

    /**
     * Set the healthEventType property: In case of an availability impacting event, it describes when the health
     * impacting event was originated. Examples are Lifecycle, Downtime, Fault Analysis etc.
     *
     * @param healthEventType the healthEventType value to set.
     * @return the AvailabilityStatusProperties object itself.
     */
    public AvailabilityStatusProperties withHealthEventType(String healthEventType) {
        this.healthEventType = healthEventType;
        return this;
    }

    /**
     * Get the healthEventCause property: In case of an availability impacting event, it describes where the health
     * impacting event was originated. Examples are PlatformInitiated, UserInitiated etc.
     *
     * @return the healthEventCause value.
     */
    public String healthEventCause() {
        return this.healthEventCause;
    }

    /**
     * Set the healthEventCause property: In case of an availability impacting event, it describes where the health
     * impacting event was originated. Examples are PlatformInitiated, UserInitiated etc.
     *
     * @param healthEventCause the healthEventCause value to set.
     * @return the AvailabilityStatusProperties object itself.
     */
    public AvailabilityStatusProperties withHealthEventCause(String healthEventCause) {
        this.healthEventCause = healthEventCause;
        return this;
    }

    /**
     * Get the healthEventCategory property: In case of an availability impacting event, it describes the category of a
     * PlatformInitiated health impacting event. Examples are Planned, Unplanned etc.
     *
     * @return the healthEventCategory value.
     */
    public String healthEventCategory() {
        return this.healthEventCategory;
    }

    /**
     * Set the healthEventCategory property: In case of an availability impacting event, it describes the category of a
     * PlatformInitiated health impacting event. Examples are Planned, Unplanned etc.
     *
     * @param healthEventCategory the healthEventCategory value to set.
     * @return the AvailabilityStatusProperties object itself.
     */
    public AvailabilityStatusProperties withHealthEventCategory(String healthEventCategory) {
        this.healthEventCategory = healthEventCategory;
        return this;
    }

    /**
     * Get the healthEventId property: It is a unique Id that identifies the event.
     *
     * @return the healthEventId value.
     */
    public String healthEventId() {
        return this.healthEventId;
    }

    /**
     * Set the healthEventId property: It is a unique Id that identifies the event.
     *
     * @param healthEventId the healthEventId value to set.
     * @return the AvailabilityStatusProperties object itself.
     */
    public AvailabilityStatusProperties withHealthEventId(String healthEventId) {
        this.healthEventId = healthEventId;
        return this;
    }

    /**
     * Get the resolutionEta property: When the resource's availabilityState is Unavailable and the reasonType is not
     * User Initiated, it provides the date and time for when the issue is expected to be resolved.
     *
     * @return the resolutionEta value.
     */
    public OffsetDateTime resolutionEta() {
        return this.resolutionEta;
    }

    /**
     * Set the resolutionEta property: When the resource's availabilityState is Unavailable and the reasonType is not
     * User Initiated, it provides the date and time for when the issue is expected to be resolved.
     *
     * @param resolutionEta the resolutionEta value to set.
     * @return the AvailabilityStatusProperties object itself.
     */
    public AvailabilityStatusProperties withResolutionEta(OffsetDateTime resolutionEta) {
        this.resolutionEta = resolutionEta;
        return this;
    }

    /**
     * Get the occuredTime property: Timestamp for when last change in health status occurred.
     *
     * @return the occuredTime value.
     */
    public OffsetDateTime occuredTime() {
        return this.occuredTime;
    }

    /**
     * Set the occuredTime property: Timestamp for when last change in health status occurred.
     *
     * @param occuredTime the occuredTime value to set.
     * @return the AvailabilityStatusProperties object itself.
     */
    public AvailabilityStatusProperties withOccuredTime(OffsetDateTime occuredTime) {
        this.occuredTime = occuredTime;
        return this;
    }

    /**
     * Get the reasonChronicity property: Chronicity of the availability transition.
     *
     * @return the reasonChronicity value.
     */
    public ReasonChronicityTypes reasonChronicity() {
        return this.reasonChronicity;
    }

    /**
     * Set the reasonChronicity property: Chronicity of the availability transition.
     *
     * @param reasonChronicity the reasonChronicity value to set.
     * @return the AvailabilityStatusProperties object itself.
     */
    public AvailabilityStatusProperties withReasonChronicity(ReasonChronicityTypes reasonChronicity) {
        this.reasonChronicity = reasonChronicity;
        return this;
    }

    /**
     * Get the reportedTime property: Timestamp for when the health was last checked.
     *
     * @return the reportedTime value.
     */
    public OffsetDateTime reportedTime() {
        return this.reportedTime;
    }

    /**
     * Set the reportedTime property: Timestamp for when the health was last checked.
     *
     * @param reportedTime the reportedTime value to set.
     * @return the AvailabilityStatusProperties object itself.
     */
    public AvailabilityStatusProperties withReportedTime(OffsetDateTime reportedTime) {
        this.reportedTime = reportedTime;
        return this;
    }

    /**
     * Get the recentlyResolved property: An annotation describing a change in the availabilityState to Available from
     * Unavailable with a reasonType of type Unplanned.
     *
     * @return the recentlyResolved value.
     */
    public AvailabilityStatusPropertiesRecentlyResolved recentlyResolved() {
        return this.recentlyResolved;
    }

    /**
     * Set the recentlyResolved property: An annotation describing a change in the availabilityState to Available from
     * Unavailable with a reasonType of type Unplanned.
     *
     * @param recentlyResolved the recentlyResolved value to set.
     * @return the AvailabilityStatusProperties object itself.
     */
    public AvailabilityStatusProperties withRecentlyResolved(
        AvailabilityStatusPropertiesRecentlyResolved recentlyResolved) {
        this.recentlyResolved = recentlyResolved;
        return this;
    }

    /**
     * Get the recommendedActions property: Lists actions the user can take based on the current availabilityState of
     * the resource.
     *
     * @return the recommendedActions value.
     */
    public List<RecommendedAction> recommendedActions() {
        return this.recommendedActions;
    }

    /**
     * Set the recommendedActions property: Lists actions the user can take based on the current availabilityState of
     * the resource.
     *
     * @param recommendedActions the recommendedActions value to set.
     * @return the AvailabilityStatusProperties object itself.
     */
    public AvailabilityStatusProperties withRecommendedActions(List<RecommendedAction> recommendedActions) {
        this.recommendedActions = recommendedActions;
        return this;
    }

    /**
     * Get the serviceImpactingEvents property: Lists the service impacting events that may be affecting the health of
     * the resource.
     *
     * @return the serviceImpactingEvents value.
     */
    public List<ServiceImpactingEvent> serviceImpactingEvents() {
        return this.serviceImpactingEvents;
    }

    /**
     * Set the serviceImpactingEvents property: Lists the service impacting events that may be affecting the health of
     * the resource.
     *
     * @param serviceImpactingEvents the serviceImpactingEvents value to set.
     * @return the AvailabilityStatusProperties object itself.
     */
    public AvailabilityStatusProperties withServiceImpactingEvents(List<ServiceImpactingEvent> serviceImpactingEvents) {
        this.serviceImpactingEvents = serviceImpactingEvents;
        return this;
    }

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