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

com.azure.resourcemanager.securityinsights.models.AnomalyTimelineItem 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;
import java.util.List;

/**
 * Represents anomaly timeline item.
 */
@Fluent
public final class AnomalyTimelineItem extends EntityTimelineItem {
    /*
     * The entity query kind type.
     */
    private EntityTimelineKind kind = EntityTimelineKind.ANOMALY;

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

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

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

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

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

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

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

    /*
     * The name of the anomaly vendor.
     */
    private String vendor;

    /*
     * The intent of the anomaly.
     */
    private String intent;

    /*
     * The techniques of the anomaly.
     */
    private List techniques;

    /*
     * The reasons that cause the anomaly.
     */
    private List reasons;

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

    /**
     * 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 anomaly azure resource id.
     * 
     * @return the azureResourceId value.
     */
    public String azureResourceId() {
        return this.azureResourceId;
    }

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

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

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

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

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

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

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

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

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

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

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

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

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

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

    /**
     * Set the vendor property: The name of the anomaly vendor.
     * 
     * @param vendor the vendor value to set.
     * @return the AnomalyTimelineItem object itself.
     */
    public AnomalyTimelineItem withVendor(String vendor) {
        this.vendor = vendor;
        return this;
    }

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

    /**
     * Set the intent property: The intent of the anomaly.
     * 
     * @param intent the intent value to set.
     * @return the AnomalyTimelineItem object itself.
     */
    public AnomalyTimelineItem withIntent(String intent) {
        this.intent = intent;
        return this;
    }

    /**
     * Get the techniques property: The techniques of the anomaly.
     * 
     * @return the techniques value.
     */
    public List techniques() {
        return this.techniques;
    }

    /**
     * Set the techniques property: The techniques of the anomaly.
     * 
     * @param techniques the techniques value to set.
     * @return the AnomalyTimelineItem object itself.
     */
    public AnomalyTimelineItem withTechniques(List techniques) {
        this.techniques = techniques;
        return this;
    }

    /**
     * Get the reasons property: The reasons that cause the anomaly.
     * 
     * @return the reasons value.
     */
    public List reasons() {
        return this.reasons;
    }

    /**
     * Set the reasons property: The reasons that cause the anomaly.
     * 
     * @param reasons the reasons value to set.
     * @return the AnomalyTimelineItem object itself.
     */
    public AnomalyTimelineItem withReasons(List reasons) {
        this.reasons = reasons;
        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 AnomalyTimelineItem"));
        }
        if (displayName() == null) {
            throw LOGGER.atError()
                .log(
                    new IllegalArgumentException("Missing required property displayName in model AnomalyTimelineItem"));
        }
        if (endTimeUtc() == null) {
            throw LOGGER.atError()
                .log(new IllegalArgumentException("Missing required property endTimeUtc in model AnomalyTimelineItem"));
        }
        if (startTimeUtc() == null) {
            throw LOGGER.atError()
                .log(new IllegalArgumentException(
                    "Missing required property startTimeUtc in model AnomalyTimelineItem"));
        }
        if (timeGenerated() == null) {
            throw LOGGER.atError()
                .log(new IllegalArgumentException(
                    "Missing required property timeGenerated in model AnomalyTimelineItem"));
        }
    }

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

    /**
     * {@inheritDoc}
     */
    @Override
    public JsonWriter toJson(JsonWriter jsonWriter) throws IOException {
        jsonWriter.writeStartObject();
        jsonWriter.writeStringField("azureResourceId", this.azureResourceId);
        jsonWriter.writeStringField("displayName", this.displayName);
        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("kind", this.kind == null ? null : this.kind.toString());
        jsonWriter.writeStringField("productName", this.productName);
        jsonWriter.writeStringField("description", this.description);
        jsonWriter.writeStringField("vendor", this.vendor);
        jsonWriter.writeStringField("intent", this.intent);
        jsonWriter.writeArrayField("techniques", this.techniques, (writer, element) -> writer.writeString(element));
        jsonWriter.writeArrayField("reasons", this.reasons, (writer, element) -> writer.writeString(element));
        return jsonWriter.writeEndObject();
    }

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

                if ("azureResourceId".equals(fieldName)) {
                    deserializedAnomalyTimelineItem.azureResourceId = reader.getString();
                } else if ("displayName".equals(fieldName)) {
                    deserializedAnomalyTimelineItem.displayName = reader.getString();
                } else if ("endTimeUtc".equals(fieldName)) {
                    deserializedAnomalyTimelineItem.endTimeUtc = reader
                        .getNullable(nonNullReader -> CoreUtils.parseBestOffsetDateTime(nonNullReader.getString()));
                } else if ("startTimeUtc".equals(fieldName)) {
                    deserializedAnomalyTimelineItem.startTimeUtc = reader
                        .getNullable(nonNullReader -> CoreUtils.parseBestOffsetDateTime(nonNullReader.getString()));
                } else if ("timeGenerated".equals(fieldName)) {
                    deserializedAnomalyTimelineItem.timeGenerated = reader
                        .getNullable(nonNullReader -> CoreUtils.parseBestOffsetDateTime(nonNullReader.getString()));
                } else if ("kind".equals(fieldName)) {
                    deserializedAnomalyTimelineItem.kind = EntityTimelineKind.fromString(reader.getString());
                } else if ("productName".equals(fieldName)) {
                    deserializedAnomalyTimelineItem.productName = reader.getString();
                } else if ("description".equals(fieldName)) {
                    deserializedAnomalyTimelineItem.description = reader.getString();
                } else if ("vendor".equals(fieldName)) {
                    deserializedAnomalyTimelineItem.vendor = reader.getString();
                } else if ("intent".equals(fieldName)) {
                    deserializedAnomalyTimelineItem.intent = reader.getString();
                } else if ("techniques".equals(fieldName)) {
                    List techniques = reader.readArray(reader1 -> reader1.getString());
                    deserializedAnomalyTimelineItem.techniques = techniques;
                } else if ("reasons".equals(fieldName)) {
                    List reasons = reader.readArray(reader1 -> reader1.getString());
                    deserializedAnomalyTimelineItem.reasons = reasons;
                } else {
                    reader.skipChildren();
                }
            }

            return deserializedAnomalyTimelineItem;
        });
    }
}




© 2015 - 2025 Weber Informatics LLC | Privacy Policy