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

com.azure.resourcemanager.securityinsights.models.SecurityAlertTimelineItem Maven / Gradle / Ivy

Go to download

This package contains Microsoft Azure SDK for SecurityInsights Management SDK. For documentation on how to use this package, please see https://aka.ms/azsdk/java/mgmt. API spec for Microsoft.SecurityInsights (Azure Security Insights) resource provider. Package tag package-preview-2021-09.

There is a newer version: 1.0.0
Show 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.securityinsights.models;

import com.azure.core.annotation.Fluent;
import com.azure.core.util.CoreUtils;
import com.azure.core.util.logging.ClientLogger;
import com.azure.json.JsonReader;
import com.azure.json.JsonToken;
import com.azure.json.JsonWriter;
import java.io.IOException;
import java.time.OffsetDateTime;
import java.time.format.DateTimeFormatter;

/**
 * Represents security alert timeline item.
 */
@Fluent
public final class SecurityAlertTimelineItem extends EntityTimelineItem {
    /*
     * The entity query kind type.
     */
    private EntityTimelineKind kind = EntityTimelineKind.SECURITY_ALERT;

    /*
     * The alert azure resource id.
     */
    private String azureResourceId;

    /*
     * The alert product name.
     */
    private String productName;

    /*
     * The alert description.
     */
    private String description;

    /*
     * The alert name.
     */
    private String displayName;

    /*
     * The alert severity.
     */
    private AlertSeverity severity;

    /*
     * The alert end time.
     */
    private OffsetDateTime endTimeUtc;

    /*
     * The alert start time.
     */
    private OffsetDateTime startTimeUtc;

    /*
     * The alert generated time.
     */
    private OffsetDateTime timeGenerated;

    /*
     * The name of the alert type.
     */
    private String alertType;

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

    /**
     * Get the kind property: The entity query kind type.
     * 
     * @return the kind value.
     */
    @Override
    public EntityTimelineKind kind() {
        return this.kind;
    }

    /**
     * Get the azureResourceId property: The alert azure resource id.
     * 
     * @return the azureResourceId value.
     */
    public String azureResourceId() {
        return this.azureResourceId;
    }

    /**
     * Set the azureResourceId property: The alert azure resource id.
     * 
     * @param azureResourceId the azureResourceId value to set.
     * @return the SecurityAlertTimelineItem object itself.
     */
    public SecurityAlertTimelineItem withAzureResourceId(String azureResourceId) {
        this.azureResourceId = azureResourceId;
        return this;
    }

    /**
     * Get the productName property: The alert product name.
     * 
     * @return the productName value.
     */
    public String productName() {
        return this.productName;
    }

    /**
     * Set the productName property: The alert product name.
     * 
     * @param productName the productName value to set.
     * @return the SecurityAlertTimelineItem object itself.
     */
    public SecurityAlertTimelineItem withProductName(String productName) {
        this.productName = productName;
        return this;
    }

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

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

    /**
     * Get the displayName property: The alert name.
     * 
     * @return the displayName value.
     */
    public String displayName() {
        return this.displayName;
    }

    /**
     * Set the displayName property: The alert name.
     * 
     * @param displayName the displayName value to set.
     * @return the SecurityAlertTimelineItem object itself.
     */
    public SecurityAlertTimelineItem withDisplayName(String displayName) {
        this.displayName = displayName;
        return this;
    }

    /**
     * Get the severity property: The alert severity.
     * 
     * @return the severity value.
     */
    public AlertSeverity severity() {
        return this.severity;
    }

    /**
     * Set the severity property: The alert severity.
     * 
     * @param severity the severity value to set.
     * @return the SecurityAlertTimelineItem object itself.
     */
    public SecurityAlertTimelineItem withSeverity(AlertSeverity severity) {
        this.severity = severity;
        return this;
    }

    /**
     * Get the endTimeUtc property: The alert end time.
     * 
     * @return the endTimeUtc value.
     */
    public OffsetDateTime endTimeUtc() {
        return this.endTimeUtc;
    }

    /**
     * Set the endTimeUtc property: The alert end time.
     * 
     * @param endTimeUtc the endTimeUtc value to set.
     * @return the SecurityAlertTimelineItem object itself.
     */
    public SecurityAlertTimelineItem withEndTimeUtc(OffsetDateTime endTimeUtc) {
        this.endTimeUtc = endTimeUtc;
        return this;
    }

    /**
     * Get the startTimeUtc property: The alert start time.
     * 
     * @return the startTimeUtc value.
     */
    public OffsetDateTime startTimeUtc() {
        return this.startTimeUtc;
    }

    /**
     * Set the startTimeUtc property: The alert start time.
     * 
     * @param startTimeUtc the startTimeUtc value to set.
     * @return the SecurityAlertTimelineItem object itself.
     */
    public SecurityAlertTimelineItem withStartTimeUtc(OffsetDateTime startTimeUtc) {
        this.startTimeUtc = startTimeUtc;
        return this;
    }

    /**
     * Get the timeGenerated property: The alert generated time.
     * 
     * @return the timeGenerated value.
     */
    public OffsetDateTime timeGenerated() {
        return this.timeGenerated;
    }

    /**
     * Set the timeGenerated property: The alert generated time.
     * 
     * @param timeGenerated the timeGenerated value to set.
     * @return the SecurityAlertTimelineItem object itself.
     */
    public SecurityAlertTimelineItem withTimeGenerated(OffsetDateTime timeGenerated) {
        this.timeGenerated = timeGenerated;
        return this;
    }

    /**
     * Get the alertType property: The name of the alert type.
     * 
     * @return the alertType value.
     */
    public String alertType() {
        return this.alertType;
    }

    /**
     * Set the alertType property: The name of the alert type.
     * 
     * @param alertType the alertType value to set.
     * @return the SecurityAlertTimelineItem object itself.
     */
    public SecurityAlertTimelineItem withAlertType(String alertType) {
        this.alertType = alertType;
        return this;
    }

    /**
     * Validates the instance.
     * 
     * @throws IllegalArgumentException thrown if the instance is not valid.
     */
    @Override
    public void validate() {
        if (azureResourceId() == null) {
            throw LOGGER.atError()
                .log(new IllegalArgumentException(
                    "Missing required property azureResourceId in model SecurityAlertTimelineItem"));
        }
        if (displayName() == null) {
            throw LOGGER.atError()
                .log(new IllegalArgumentException(
                    "Missing required property displayName in model SecurityAlertTimelineItem"));
        }
        if (severity() == null) {
            throw LOGGER.atError()
                .log(new IllegalArgumentException(
                    "Missing required property severity in model SecurityAlertTimelineItem"));
        }
        if (endTimeUtc() == null) {
            throw LOGGER.atError()
                .log(new IllegalArgumentException(
                    "Missing required property endTimeUtc in model SecurityAlertTimelineItem"));
        }
        if (startTimeUtc() == null) {
            throw LOGGER.atError()
                .log(new IllegalArgumentException(
                    "Missing required property startTimeUtc in model SecurityAlertTimelineItem"));
        }
        if (timeGenerated() == null) {
            throw LOGGER.atError()
                .log(new IllegalArgumentException(
                    "Missing required property timeGenerated in model SecurityAlertTimelineItem"));
        }
        if (alertType() == null) {
            throw LOGGER.atError()
                .log(new IllegalArgumentException(
                    "Missing required property alertType in model SecurityAlertTimelineItem"));
        }
    }

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

    /**
     * {@inheritDoc}
     */
    @Override
    public JsonWriter toJson(JsonWriter jsonWriter) throws IOException {
        jsonWriter.writeStartObject();
        jsonWriter.writeStringField("azureResourceId", this.azureResourceId);
        jsonWriter.writeStringField("displayName", this.displayName);
        jsonWriter.writeStringField("severity", this.severity == null ? null : this.severity.toString());
        jsonWriter.writeStringField("endTimeUtc",
            this.endTimeUtc == null ? null : DateTimeFormatter.ISO_OFFSET_DATE_TIME.format(this.endTimeUtc));
        jsonWriter.writeStringField("startTimeUtc",
            this.startTimeUtc == null ? null : DateTimeFormatter.ISO_OFFSET_DATE_TIME.format(this.startTimeUtc));
        jsonWriter.writeStringField("timeGenerated",
            this.timeGenerated == null ? null : DateTimeFormatter.ISO_OFFSET_DATE_TIME.format(this.timeGenerated));
        jsonWriter.writeStringField("alertType", this.alertType);
        jsonWriter.writeStringField("kind", this.kind == null ? null : this.kind.toString());
        jsonWriter.writeStringField("productName", this.productName);
        jsonWriter.writeStringField("description", this.description);
        return jsonWriter.writeEndObject();
    }

    /**
     * Reads an instance of SecurityAlertTimelineItem from the JsonReader.
     * 
     * @param jsonReader The JsonReader being read.
     * @return An instance of SecurityAlertTimelineItem if the JsonReader was pointing to an instance of it, or null if
     * it was pointing to JSON null.
     * @throws IllegalStateException If the deserialized JSON object was missing any required properties.
     * @throws IOException If an error occurs while reading the SecurityAlertTimelineItem.
     */
    public static SecurityAlertTimelineItem fromJson(JsonReader jsonReader) throws IOException {
        return jsonReader.readObject(reader -> {
            SecurityAlertTimelineItem deserializedSecurityAlertTimelineItem = new SecurityAlertTimelineItem();
            while (reader.nextToken() != JsonToken.END_OBJECT) {
                String fieldName = reader.getFieldName();
                reader.nextToken();

                if ("azureResourceId".equals(fieldName)) {
                    deserializedSecurityAlertTimelineItem.azureResourceId = reader.getString();
                } else if ("displayName".equals(fieldName)) {
                    deserializedSecurityAlertTimelineItem.displayName = reader.getString();
                } else if ("severity".equals(fieldName)) {
                    deserializedSecurityAlertTimelineItem.severity = AlertSeverity.fromString(reader.getString());
                } else if ("endTimeUtc".equals(fieldName)) {
                    deserializedSecurityAlertTimelineItem.endTimeUtc = reader
                        .getNullable(nonNullReader -> CoreUtils.parseBestOffsetDateTime(nonNullReader.getString()));
                } else if ("startTimeUtc".equals(fieldName)) {
                    deserializedSecurityAlertTimelineItem.startTimeUtc = reader
                        .getNullable(nonNullReader -> CoreUtils.parseBestOffsetDateTime(nonNullReader.getString()));
                } else if ("timeGenerated".equals(fieldName)) {
                    deserializedSecurityAlertTimelineItem.timeGenerated = reader
                        .getNullable(nonNullReader -> CoreUtils.parseBestOffsetDateTime(nonNullReader.getString()));
                } else if ("alertType".equals(fieldName)) {
                    deserializedSecurityAlertTimelineItem.alertType = reader.getString();
                } else if ("kind".equals(fieldName)) {
                    deserializedSecurityAlertTimelineItem.kind = EntityTimelineKind.fromString(reader.getString());
                } else if ("productName".equals(fieldName)) {
                    deserializedSecurityAlertTimelineItem.productName = reader.getString();
                } else if ("description".equals(fieldName)) {
                    deserializedSecurityAlertTimelineItem.description = reader.getString();
                } else {
                    reader.skipChildren();
                }
            }

            return deserializedSecurityAlertTimelineItem;
        });
    }
}




© 2015 - 2025 Weber Informatics LLC | Privacy Policy