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

com.azure.resourcemanager.securityinsights.fluent.models.IncidentCommentProperties 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.fluent.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 com.azure.resourcemanager.securityinsights.models.ClientInfo;
import java.io.IOException;
import java.time.OffsetDateTime;

/**
 * Incident comment property bag.
 */
@Fluent
public final class IncidentCommentProperties implements JsonSerializable {
    /*
     * The time the comment was created
     */
    private OffsetDateTime createdTimeUtc;

    /*
     * The time the comment was updated
     */
    private OffsetDateTime lastModifiedTimeUtc;

    /*
     * The comment message
     */
    private String message;

    /*
     * Describes the client that created the comment
     */
    private ClientInfo author;

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

    /**
     * Get the createdTimeUtc property: The time the comment was created.
     * 
     * @return the createdTimeUtc value.
     */
    public OffsetDateTime createdTimeUtc() {
        return this.createdTimeUtc;
    }

    /**
     * Get the lastModifiedTimeUtc property: The time the comment was updated.
     * 
     * @return the lastModifiedTimeUtc value.
     */
    public OffsetDateTime lastModifiedTimeUtc() {
        return this.lastModifiedTimeUtc;
    }

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

    /**
     * Set the message property: The comment message.
     * 
     * @param message the message value to set.
     * @return the IncidentCommentProperties object itself.
     */
    public IncidentCommentProperties withMessage(String message) {
        this.message = message;
        return this;
    }

    /**
     * Get the author property: Describes the client that created the comment.
     * 
     * @return the author value.
     */
    public ClientInfo author() {
        return this.author;
    }

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

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

    /**
     * {@inheritDoc}
     */
    @Override
    public JsonWriter toJson(JsonWriter jsonWriter) throws IOException {
        jsonWriter.writeStartObject();
        jsonWriter.writeStringField("message", this.message);
        return jsonWriter.writeEndObject();
    }

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

                if ("message".equals(fieldName)) {
                    deserializedIncidentCommentProperties.message = reader.getString();
                } else if ("createdTimeUtc".equals(fieldName)) {
                    deserializedIncidentCommentProperties.createdTimeUtc = reader
                        .getNullable(nonNullReader -> CoreUtils.parseBestOffsetDateTime(nonNullReader.getString()));
                } else if ("lastModifiedTimeUtc".equals(fieldName)) {
                    deserializedIncidentCommentProperties.lastModifiedTimeUtc = reader
                        .getNullable(nonNullReader -> CoreUtils.parseBestOffsetDateTime(nonNullReader.getString()));
                } else if ("author".equals(fieldName)) {
                    deserializedIncidentCommentProperties.author = ClientInfo.fromJson(reader);
                } else {
                    reader.skipChildren();
                }
            }

            return deserializedIncidentCommentProperties;
        });
    }
}




© 2015 - 2024 Weber Informatics LLC | Privacy Policy