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

com.azure.resourcemanager.securityinsights.models.EntityInsightItemQueryTimeInterval 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.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;

/**
 * The Time interval that the query actually executed on.
 */
@Fluent
public final class EntityInsightItemQueryTimeInterval implements JsonSerializable {
    /*
     * Insight query start time
     */
    private OffsetDateTime startTime;

    /*
     * Insight query end time
     */
    private OffsetDateTime endTime;

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

    /**
     * Get the startTime property: Insight query start time.
     * 
     * @return the startTime value.
     */
    public OffsetDateTime startTime() {
        return this.startTime;
    }

    /**
     * Set the startTime property: Insight query start time.
     * 
     * @param startTime the startTime value to set.
     * @return the EntityInsightItemQueryTimeInterval object itself.
     */
    public EntityInsightItemQueryTimeInterval withStartTime(OffsetDateTime startTime) {
        this.startTime = startTime;
        return this;
    }

    /**
     * Get the endTime property: Insight query end time.
     * 
     * @return the endTime value.
     */
    public OffsetDateTime endTime() {
        return this.endTime;
    }

    /**
     * Set the endTime property: Insight query end time.
     * 
     * @param endTime the endTime value to set.
     * @return the EntityInsightItemQueryTimeInterval object itself.
     */
    public EntityInsightItemQueryTimeInterval withEndTime(OffsetDateTime endTime) {
        this.endTime = endTime;
        return this;
    }

    /**
     * Validates the instance.
     * 
     * @throws IllegalArgumentException thrown if the instance is not valid.
     */
    public void validate() {
    }

    /**
     * {@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));
        return jsonWriter.writeEndObject();
    }

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

                if ("startTime".equals(fieldName)) {
                    deserializedEntityInsightItemQueryTimeInterval.startTime = reader
                        .getNullable(nonNullReader -> CoreUtils.parseBestOffsetDateTime(nonNullReader.getString()));
                } else if ("endTime".equals(fieldName)) {
                    deserializedEntityInsightItemQueryTimeInterval.endTime = reader
                        .getNullable(nonNullReader -> CoreUtils.parseBestOffsetDateTime(nonNullReader.getString()));
                } else {
                    reader.skipChildren();
                }
            }

            return deserializedEntityInsightItemQueryTimeInterval;
        });
    }
}




© 2015 - 2025 Weber Informatics LLC | Privacy Policy