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

com.azure.messaging.eventgrid.systemevents.RedisExportRdbCompletedEventData 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.ExportRDBCompleted event.
 */
@Fluent
public final class RedisExportRdbCompletedEventData 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 RedisExportRdbCompletedEventData class.
     */
    public RedisExportRdbCompletedEventData() {
    }

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

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

            return deserializedRedisExportRdbCompletedEventData;
        });
    }
}




© 2015 - 2024 Weber Informatics LLC | Privacy Policy