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

package com.azure.resourcemanager.securityinsights.fluent.models;

import com.azure.core.annotation.Fluent;
import com.azure.core.util.logging.ClientLogger;
import com.azure.resourcemanager.securityinsights.models.IncidentAdditionalData;
import com.azure.resourcemanager.securityinsights.models.IncidentClassification;
import com.azure.resourcemanager.securityinsights.models.IncidentClassificationReason;
import com.azure.resourcemanager.securityinsights.models.IncidentLabel;
import com.azure.resourcemanager.securityinsights.models.IncidentOwnerInfo;
import com.azure.resourcemanager.securityinsights.models.IncidentSeverity;
import com.azure.resourcemanager.securityinsights.models.IncidentStatus;
import com.fasterxml.jackson.annotation.JsonProperty;
import java.time.OffsetDateTime;
import java.util.List;

/** Describes incident properties. */
@Fluent
public final class IncidentPropertiesInner {
    /*
     * Additional data on the incident
     */
    @JsonProperty(value = "additionalData", access = JsonProperty.Access.WRITE_ONLY)
    private IncidentAdditionalData additionalData;

    /*
     * The reason the incident was closed
     */
    @JsonProperty(value = "classification")
    private IncidentClassification classification;

    /*
     * Describes the reason the incident was closed
     */
    @JsonProperty(value = "classificationComment")
    private String classificationComment;

    /*
     * The classification reason the incident was closed with
     */
    @JsonProperty(value = "classificationReason")
    private IncidentClassificationReason classificationReason;

    /*
     * The time the incident was created
     */
    @JsonProperty(value = "createdTimeUtc", access = JsonProperty.Access.WRITE_ONLY)
    private OffsetDateTime createdTimeUtc;

    /*
     * The description of the incident
     */
    @JsonProperty(value = "description")
    private String description;

    /*
     * The time of the first activity in the incident
     */
    @JsonProperty(value = "firstActivityTimeUtc")
    private OffsetDateTime firstActivityTimeUtc;

    /*
     * The deep-link url to the incident in Azure portal
     */
    @JsonProperty(value = "incidentUrl", access = JsonProperty.Access.WRITE_ONLY)
    private String incidentUrl;

    /*
     * A sequential number
     */
    @JsonProperty(value = "incidentNumber", access = JsonProperty.Access.WRITE_ONLY)
    private Integer incidentNumber;

    /*
     * List of labels relevant to this incident
     */
    @JsonProperty(value = "labels")
    private List<IncidentLabel> labels;

    /*
     * The name of the source provider that generated the incident
     */
    @JsonProperty(value = "providerName")
    private String providerName;

    /*
     * The incident ID assigned by the incident provider
     */
    @JsonProperty(value = "providerIncidentId")
    private String providerIncidentId;

    /*
     * The time of the last activity in the incident
     */
    @JsonProperty(value = "lastActivityTimeUtc")
    private OffsetDateTime lastActivityTimeUtc;

    /*
     * The last time the incident was updated
     */
    @JsonProperty(value = "lastModifiedTimeUtc", access = JsonProperty.Access.WRITE_ONLY)
    private OffsetDateTime lastModifiedTimeUtc;

    /*
     * Describes a user that the incident is assigned to
     */
    @JsonProperty(value = "owner")
    private IncidentOwnerInfo owner;

    /*
     * List of resource ids of Analytic rules related to the incident
     */
    @JsonProperty(value = "relatedAnalyticRuleIds", access = JsonProperty.Access.WRITE_ONLY)
    private List<String> relatedAnalyticRuleIds;

    /*
     * The severity of the incident
     */
    @JsonProperty(value = "severity", required = true)
    private IncidentSeverity severity;

    /*
     * The status of the incident
     */
    @JsonProperty(value = "status", required = true)
    private IncidentStatus status;

    /*
     * Describes a team for the incident
     */
    @JsonProperty(value = "teamInformation")
    private TeamInformationInner teamInformation;

    /*
     * The title of the incident
     */
    @JsonProperty(value = "title", required = true)
    private String title;

    /**
     * Get the additionalData property: Additional data on the incident.
     *
     * @return the additionalData value.
     */
    public IncidentAdditionalData additionalData() {
        return this.additionalData;
    }

    /**
     * Get the classification property: The reason the incident was closed.
     *
     * @return the classification value.
     */
    public IncidentClassification classification() {
        return this.classification;
    }

    /**
     * Set the classification property: The reason the incident was closed.
     *
     * @param classification the classification value to set.
     * @return the IncidentPropertiesInner object itself.
     */
    public IncidentPropertiesInner withClassification(IncidentClassification classification) {
        this.classification = classification;
        return this;
    }

    /**
     * Get the classificationComment property: Describes the reason the incident was closed.
     *
     * @return the classificationComment value.
     */
    public String classificationComment() {
        return this.classificationComment;
    }

    /**
     * Set the classificationComment property: Describes the reason the incident was closed.
     *
     * @param classificationComment the classificationComment value to set.
     * @return the IncidentPropertiesInner object itself.
     */
    public IncidentPropertiesInner withClassificationComment(String classificationComment) {
        this.classificationComment = classificationComment;
        return this;
    }

    /**
     * Get the classificationReason property: The classification reason the incident was closed with.
     *
     * @return the classificationReason value.
     */
    public IncidentClassificationReason classificationReason() {
        return this.classificationReason;
    }

    /**
     * Set the classificationReason property: The classification reason the incident was closed with.
     *
     * @param classificationReason the classificationReason value to set.
     * @return the IncidentPropertiesInner object itself.
     */
    public IncidentPropertiesInner withClassificationReason(IncidentClassificationReason classificationReason) {
        this.classificationReason = classificationReason;
        return this;
    }

    /**
     * Get the createdTimeUtc property: The time the incident was created.
     *
     * @return the createdTimeUtc value.
     */
    public OffsetDateTime createdTimeUtc() {
        return this.createdTimeUtc;
    }

    /**
     * Get the description property: The description of the incident.
     *
     * @return the description value.
     */
    public String description() {
        return this.description;
    }

    /**
     * Set the description property: The description of the incident.
     *
     * @param description the description value to set.
     * @return the IncidentPropertiesInner object itself.
     */
    public IncidentPropertiesInner withDescription(String description) {
        this.description = description;
        return this;
    }

    /**
     * Get the firstActivityTimeUtc property: The time of the first activity in the incident.
     *
     * @return the firstActivityTimeUtc value.
     */
    public OffsetDateTime firstActivityTimeUtc() {
        return this.firstActivityTimeUtc;
    }

    /**
     * Set the firstActivityTimeUtc property: The time of the first activity in the incident.
     *
     * @param firstActivityTimeUtc the firstActivityTimeUtc value to set.
     * @return the IncidentPropertiesInner object itself.
     */
    public IncidentPropertiesInner withFirstActivityTimeUtc(OffsetDateTime firstActivityTimeUtc) {
        this.firstActivityTimeUtc = firstActivityTimeUtc;
        return this;
    }

    /**
     * Get the incidentUrl property: The deep-link url to the incident in Azure portal.
     *
     * @return the incidentUrl value.
     */
    public String incidentUrl() {
        return this.incidentUrl;
    }

    /**
     * Get the incidentNumber property: A sequential number.
     *
     * @return the incidentNumber value.
     */
    public Integer incidentNumber() {
        return this.incidentNumber;
    }

    /**
     * Get the labels property: List of labels relevant to this incident.
     *
     * @return the labels value.
     */
    public List<IncidentLabel> labels() {
        return this.labels;
    }

    /**
     * Set the labels property: List of labels relevant to this incident.
     *
     * @param labels the labels value to set.
     * @return the IncidentPropertiesInner object itself.
     */
    public IncidentPropertiesInner withLabels(List<IncidentLabel> labels) {
        this.labels = labels;
        return this;
    }

    /**
     * Get the providerName property: The name of the source provider that generated the incident.
     *
     * @return the providerName value.
     */
    public String providerName() {
        return this.providerName;
    }

    /**
     * Set the providerName property: The name of the source provider that generated the incident.
     *
     * @param providerName the providerName value to set.
     * @return the IncidentPropertiesInner object itself.
     */
    public IncidentPropertiesInner withProviderName(String providerName) {
        this.providerName = providerName;
        return this;
    }

    /**
     * Get the providerIncidentId property: The incident ID assigned by the incident provider.
     *
     * @return the providerIncidentId value.
     */
    public String providerIncidentId() {
        return this.providerIncidentId;
    }

    /**
     * Set the providerIncidentId property: The incident ID assigned by the incident provider.
     *
     * @param providerIncidentId the providerIncidentId value to set.
     * @return the IncidentPropertiesInner object itself.
     */
    public IncidentPropertiesInner withProviderIncidentId(String providerIncidentId) {
        this.providerIncidentId = providerIncidentId;
        return this;
    }

    /**
     * Get the lastActivityTimeUtc property: The time of the last activity in the incident.
     *
     * @return the lastActivityTimeUtc value.
     */
    public OffsetDateTime lastActivityTimeUtc() {
        return this.lastActivityTimeUtc;
    }

    /**
     * Set the lastActivityTimeUtc property: The time of the last activity in the incident.
     *
     * @param lastActivityTimeUtc the lastActivityTimeUtc value to set.
     * @return the IncidentPropertiesInner object itself.
     */
    public IncidentPropertiesInner withLastActivityTimeUtc(OffsetDateTime lastActivityTimeUtc) {
        this.lastActivityTimeUtc = lastActivityTimeUtc;
        return this;
    }

    /**
     * Get the lastModifiedTimeUtc property: The last time the incident was updated.
     *
     * @return the lastModifiedTimeUtc value.
     */
    public OffsetDateTime lastModifiedTimeUtc() {
        return this.lastModifiedTimeUtc;
    }

    /**
     * Get the owner property: Describes a user that the incident is assigned to.
     *
     * @return the owner value.
     */
    public IncidentOwnerInfo owner() {
        return this.owner;
    }

    /**
     * Set the owner property: Describes a user that the incident is assigned to.
     *
     * @param owner the owner value to set.
     * @return the IncidentPropertiesInner object itself.
     */
    public IncidentPropertiesInner withOwner(IncidentOwnerInfo owner) {
        this.owner = owner;
        return this;
    }

    /**
     * Get the relatedAnalyticRuleIds property: List of resource ids of Analytic rules related to the incident.
     *
     * @return the relatedAnalyticRuleIds value.
     */
    public List<String> relatedAnalyticRuleIds() {
        return this.relatedAnalyticRuleIds;
    }

    /**
     * Get the severity property: The severity of the incident.
     *
     * @return the severity value.
     */
    public IncidentSeverity severity() {
        return this.severity;
    }

    /**
     * Set the severity property: The severity of the incident.
     *
     * @param severity the severity value to set.
     * @return the IncidentPropertiesInner object itself.
     */
    public IncidentPropertiesInner withSeverity(IncidentSeverity severity) {
        this.severity = severity;
        return this;
    }

    /**
     * Get the status property: The status of the incident.
     *
     * @return the status value.
     */
    public IncidentStatus status() {
        return this.status;
    }

    /**
     * Set the status property: The status of the incident.
     *
     * @param status the status value to set.
     * @return the IncidentPropertiesInner object itself.
     */
    public IncidentPropertiesInner withStatus(IncidentStatus status) {
        this.status = status;
        return this;
    }

    /**
     * Get the teamInformation property: Describes a team for the incident.
     *
     * @return the teamInformation value.
     */
    public TeamInformationInner teamInformation() {
        return this.teamInformation;
    }

    /**
     * Set the teamInformation property: Describes a team for the incident.
     *
     * @param teamInformation the teamInformation value to set.
     * @return the IncidentPropertiesInner object itself.
     */
    public IncidentPropertiesInner withTeamInformation(TeamInformationInner teamInformation) {
        this.teamInformation = teamInformation;
        return this;
    }

    /**
     * Get the title property: The title of the incident.
     *
     * @return the title value.
     */
    public String title() {
        return this.title;
    }

    /**
     * Set the title property: The title of the incident.
     *
     * @param title the title value to set.
     * @return the IncidentPropertiesInner object itself.
     */
    public IncidentPropertiesInner withTitle(String title) {
        this.title = title;
        return this;
    }

    /**
     * Validates the instance.
     *
     * @throws IllegalArgumentException thrown if the instance is not valid.
     */
    public void validate() {
        if (additionalData() != null) {
            additionalData().validate();
        }
        if (labels() != null) {
            labels().forEach(e -> e.validate());
        }
        if (owner() != null) {
            owner().validate();
        }
        if (severity() == null) {
            throw LOGGER
                .logExceptionAsError(
                    new IllegalArgumentException(
                        "Missing required property severity in model IncidentPropertiesInner"));
        }
        if (status() == null) {
            throw LOGGER
                .logExceptionAsError(
                    new IllegalArgumentException("Missing required property status in model IncidentPropertiesInner"));
        }
        if (teamInformation() != null) {
            teamInformation().validate();
        }
        if (title() == null) {
            throw LOGGER
                .logExceptionAsError(
                    new IllegalArgumentException("Missing required property title in model IncidentPropertiesInner"));
        }
    }

    private static final ClientLogger LOGGER = new ClientLogger(IncidentPropertiesInner.class);
}
