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

com.azure.messaging.eventgrid.systemevents.RedisPatchingCompletedEventData Maven / Gradle / Ivy

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.messaging.eventgrid.systemevents;

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;

/**
 * Schema of the Data property of an EventGridEvent for a Microsoft.Cache.PatchingCompleted event.
 */
@Fluent
public final class RedisPatchingCompletedEventData implements JsonSerializable {
    /*
     * The time at which the event occurred.
     */
    private OffsetDateTime timestamp;

    /*
     * The name of this event.
     */
    private String name;

    /*
     * The status of this event. Failed or succeeded
     */
    private String status;

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

    /**
     * Get the timestamp property: The time at which the event occurred.
     * 
     * @return the timestamp value.
     */
    public OffsetDateTime getTimestamp() {
        return this.timestamp;
    }

    /**
     * Set the timestamp property: The time at which the event occurred.
     * 
     * @param timestamp the timestamp value to set.
     * @return the RedisPatchingCompletedEventData object itself.
     */
    public RedisPatchingCompletedEventData setTimestamp(OffsetDateTime timestamp) {
        this.timestamp = timestamp;
        return this;
    }

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

    /**
     * Set the name property: The name of this event.
     * 
     * @param name the name value to set.
     * @return the RedisPatchingCompletedEventData object itself.
     */
    public RedisPatchingCompletedEventData setName(String name) {
        this.name = name;
        return this;
    }

    /**
     * Get the status property: The status of this event. Failed or succeeded.
     * 
     * @return the status value.
     */
    public String getStatus() {
        return this.status;
    }

    /**
     * Set the status property: The status of this event. Failed or succeeded.
     * 
     * @param status the status value to set.
     * @return the RedisPatchingCompletedEventData object itself.
     */
    public RedisPatchingCompletedEventData setStatus(String status) {
        this.status = status;
        return this;
    }

    /**
     * {@inheritDoc}
     */
    @Override
    public JsonWriter toJson(JsonWriter jsonWriter) throws IOException {
        jsonWriter.writeStartObject();
        jsonWriter.writeStringField("timestamp",
            this.timestamp == null ? null : DateTimeFormatter.ISO_OFFSET_DATE_TIME.format(this.timestamp));
        jsonWriter.writeStringField("name", this.name);
        jsonWriter.writeStringField("status", this.status);
        return jsonWriter.writeEndObject();
    }

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

                if ("timestamp".equals(fieldName)) {
                    deserializedRedisPatchingCompletedEventData.timestamp = reader
                        .getNullable(nonNullReader -> CoreUtils.parseBestOffsetDateTime(nonNullReader.getString()));
                } else if ("name".equals(fieldName)) {
                    deserializedRedisPatchingCompletedEventData.name = reader.getString();
                } else if ("status".equals(fieldName)) {
                    deserializedRedisPatchingCompletedEventData.status = reader.getString();
                } else {
                    reader.skipChildren();
                }
            }

            return deserializedRedisPatchingCompletedEventData;
        });
    }
}




© 2015 - 2024 Weber Informatics LLC | Privacy Policy