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

com.azure.resourcemanager.securityinsights.models.EntityInsightItem 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-2022-09.

The 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.json.JsonReader;
import com.azure.json.JsonSerializable;
import com.azure.json.JsonToken;
import com.azure.json.JsonWriter;
import java.io.IOException;
import java.util.List;

/**
 * Entity insight Item.
 */
@Fluent
public final class EntityInsightItem implements JsonSerializable {
    /*
     * The query id of the insight
     */
    private String queryId;

    /*
     * The Time interval that the query actually executed on.
     */
    private EntityInsightItemQueryTimeInterval queryTimeInterval;

    /*
     * Query results for table insights query.
     */
    private InsightsTableResult tableQueryResults;

    /*
     * Query results for table insights query.
     */
    private List chartQueryResults;

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

    /**
     * Get the queryId property: The query id of the insight.
     * 
     * @return the queryId value.
     */
    public String queryId() {
        return this.queryId;
    }

    /**
     * Set the queryId property: The query id of the insight.
     * 
     * @param queryId the queryId value to set.
     * @return the EntityInsightItem object itself.
     */
    public EntityInsightItem withQueryId(String queryId) {
        this.queryId = queryId;
        return this;
    }

    /**
     * Get the queryTimeInterval property: The Time interval that the query actually executed on.
     * 
     * @return the queryTimeInterval value.
     */
    public EntityInsightItemQueryTimeInterval queryTimeInterval() {
        return this.queryTimeInterval;
    }

    /**
     * Set the queryTimeInterval property: The Time interval that the query actually executed on.
     * 
     * @param queryTimeInterval the queryTimeInterval value to set.
     * @return the EntityInsightItem object itself.
     */
    public EntityInsightItem withQueryTimeInterval(EntityInsightItemQueryTimeInterval queryTimeInterval) {
        this.queryTimeInterval = queryTimeInterval;
        return this;
    }

    /**
     * Get the tableQueryResults property: Query results for table insights query.
     * 
     * @return the tableQueryResults value.
     */
    public InsightsTableResult tableQueryResults() {
        return this.tableQueryResults;
    }

    /**
     * Set the tableQueryResults property: Query results for table insights query.
     * 
     * @param tableQueryResults the tableQueryResults value to set.
     * @return the EntityInsightItem object itself.
     */
    public EntityInsightItem withTableQueryResults(InsightsTableResult tableQueryResults) {
        this.tableQueryResults = tableQueryResults;
        return this;
    }

    /**
     * Get the chartQueryResults property: Query results for table insights query.
     * 
     * @return the chartQueryResults value.
     */
    public List chartQueryResults() {
        return this.chartQueryResults;
    }

    /**
     * Set the chartQueryResults property: Query results for table insights query.
     * 
     * @param chartQueryResults the chartQueryResults value to set.
     * @return the EntityInsightItem object itself.
     */
    public EntityInsightItem withChartQueryResults(List chartQueryResults) {
        this.chartQueryResults = chartQueryResults;
        return this;
    }

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

    /**
     * {@inheritDoc}
     */
    @Override
    public JsonWriter toJson(JsonWriter jsonWriter) throws IOException {
        jsonWriter.writeStartObject();
        jsonWriter.writeStringField("queryId", this.queryId);
        jsonWriter.writeJsonField("queryTimeInterval", this.queryTimeInterval);
        jsonWriter.writeJsonField("tableQueryResults", this.tableQueryResults);
        jsonWriter.writeArrayField("chartQueryResults", this.chartQueryResults,
            (writer, element) -> writer.writeJson(element));
        return jsonWriter.writeEndObject();
    }

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

                if ("queryId".equals(fieldName)) {
                    deserializedEntityInsightItem.queryId = reader.getString();
                } else if ("queryTimeInterval".equals(fieldName)) {
                    deserializedEntityInsightItem.queryTimeInterval
                        = EntityInsightItemQueryTimeInterval.fromJson(reader);
                } else if ("tableQueryResults".equals(fieldName)) {
                    deserializedEntityInsightItem.tableQueryResults = InsightsTableResult.fromJson(reader);
                } else if ("chartQueryResults".equals(fieldName)) {
                    List chartQueryResults
                        = reader.readArray(reader1 -> InsightsTableResult.fromJson(reader1));
                    deserializedEntityInsightItem.chartQueryResults = chartQueryResults;
                } else {
                    reader.skipChildren();
                }
            }

            return deserializedEntityInsightItem;
        });
    }
}




© 2015 - 2024 Weber Informatics LLC | Privacy Policy