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

com.azure.resourcemanager.securityinsights.models.EntityGetInsightsParameters 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.core.util.CoreUtils;
import com.azure.core.util.logging.ClientLogger;
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.time.OffsetDateTime;
import java.time.format.DateTimeFormatter;
import java.util.List;
import java.util.Objects;
import java.util.UUID;

/**
 * The parameters required to execute insights operation on the given entity.
 */
@Fluent
public final class EntityGetInsightsParameters implements JsonSerializable {
    /*
     * The start timeline date, so the results returned are after this date.
     */
    private OffsetDateTime startTime;

    /*
     * The end timeline date, so the results returned are before this date.
     */
    private OffsetDateTime endTime;

    /*
     * Indicates if query time range should be extended with default time range of the query. Default value is false
     */
    private Boolean addDefaultExtendedTimeRange;

    /*
     * List of Insights Query Id. If empty, default value is all insights of this entity
     */
    private List insightQueryIds;

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

    /**
     * Get the startTime property: The start timeline date, so the results returned are after this date.
     * 
     * @return the startTime value.
     */
    public OffsetDateTime startTime() {
        return this.startTime;
    }

    /**
     * Set the startTime property: The start timeline date, so the results returned are after this date.
     * 
     * @param startTime the startTime value to set.
     * @return the EntityGetInsightsParameters object itself.
     */
    public EntityGetInsightsParameters withStartTime(OffsetDateTime startTime) {
        this.startTime = startTime;
        return this;
    }

    /**
     * Get the endTime property: The end timeline date, so the results returned are before this date.
     * 
     * @return the endTime value.
     */
    public OffsetDateTime endTime() {
        return this.endTime;
    }

    /**
     * Set the endTime property: The end timeline date, so the results returned are before this date.
     * 
     * @param endTime the endTime value to set.
     * @return the EntityGetInsightsParameters object itself.
     */
    public EntityGetInsightsParameters withEndTime(OffsetDateTime endTime) {
        this.endTime = endTime;
        return this;
    }

    /**
     * Get the addDefaultExtendedTimeRange property: Indicates if query time range should be extended with default time
     * range of the query. Default value is false.
     * 
     * @return the addDefaultExtendedTimeRange value.
     */
    public Boolean addDefaultExtendedTimeRange() {
        return this.addDefaultExtendedTimeRange;
    }

    /**
     * Set the addDefaultExtendedTimeRange property: Indicates if query time range should be extended with default time
     * range of the query. Default value is false.
     * 
     * @param addDefaultExtendedTimeRange the addDefaultExtendedTimeRange value to set.
     * @return the EntityGetInsightsParameters object itself.
     */
    public EntityGetInsightsParameters withAddDefaultExtendedTimeRange(Boolean addDefaultExtendedTimeRange) {
        this.addDefaultExtendedTimeRange = addDefaultExtendedTimeRange;
        return this;
    }

    /**
     * Get the insightQueryIds property: List of Insights Query Id. If empty, default value is all insights of this
     * entity.
     * 
     * @return the insightQueryIds value.
     */
    public List insightQueryIds() {
        return this.insightQueryIds;
    }

    /**
     * Set the insightQueryIds property: List of Insights Query Id. If empty, default value is all insights of this
     * entity.
     * 
     * @param insightQueryIds the insightQueryIds value to set.
     * @return the EntityGetInsightsParameters object itself.
     */
    public EntityGetInsightsParameters withInsightQueryIds(List insightQueryIds) {
        this.insightQueryIds = insightQueryIds;
        return this;
    }

    /**
     * Validates the instance.
     * 
     * @throws IllegalArgumentException thrown if the instance is not valid.
     */
    public void validate() {
        if (startTime() == null) {
            throw LOGGER.atError()
                .log(new IllegalArgumentException(
                    "Missing required property startTime in model EntityGetInsightsParameters"));
        }
        if (endTime() == null) {
            throw LOGGER.atError()
                .log(new IllegalArgumentException(
                    "Missing required property endTime in model EntityGetInsightsParameters"));
        }
    }

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

    /**
     * {@inheritDoc}
     */
    @Override
    public JsonWriter toJson(JsonWriter jsonWriter) throws IOException {
        jsonWriter.writeStartObject();
        jsonWriter.writeStringField("startTime",
            this.startTime == null ? null : DateTimeFormatter.ISO_OFFSET_DATE_TIME.format(this.startTime));
        jsonWriter.writeStringField("endTime",
            this.endTime == null ? null : DateTimeFormatter.ISO_OFFSET_DATE_TIME.format(this.endTime));
        jsonWriter.writeBooleanField("addDefaultExtendedTimeRange", this.addDefaultExtendedTimeRange);
        jsonWriter.writeArrayField("insightQueryIds", this.insightQueryIds,
            (writer, element) -> writer.writeString(Objects.toString(element, null)));
        return jsonWriter.writeEndObject();
    }

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

                if ("startTime".equals(fieldName)) {
                    deserializedEntityGetInsightsParameters.startTime = reader
                        .getNullable(nonNullReader -> CoreUtils.parseBestOffsetDateTime(nonNullReader.getString()));
                } else if ("endTime".equals(fieldName)) {
                    deserializedEntityGetInsightsParameters.endTime = reader
                        .getNullable(nonNullReader -> CoreUtils.parseBestOffsetDateTime(nonNullReader.getString()));
                } else if ("addDefaultExtendedTimeRange".equals(fieldName)) {
                    deserializedEntityGetInsightsParameters.addDefaultExtendedTimeRange
                        = reader.getNullable(JsonReader::getBoolean);
                } else if ("insightQueryIds".equals(fieldName)) {
                    List insightQueryIds = reader.readArray(
                        reader1 -> reader1.getNullable(nonNullReader -> UUID.fromString(nonNullReader.getString())));
                    deserializedEntityGetInsightsParameters.insightQueryIds = insightQueryIds;
                } else {
                    reader.skipChildren();
                }
            }

            return deserializedEntityGetInsightsParameters;
        });
    }
}




© 2015 - 2024 Weber Informatics LLC | Privacy Policy