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

com.azure.resourcemanager.mediaservices.fluent.models.LiveEventStreamEventInner Maven / Gradle / Ivy

Go to download

This package contains Microsoft Azure SDK for MediaServices Management SDK. For documentation on how to use this package, please see https://aka.ms/azsdk/java/mgmt. This Swagger was generated by the API Framework. Package tag package-account-2023-01.

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.mediaservices.fluent.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 com.azure.resourcemanager.mediaservices.models.LiveEventStreamEventData;
import com.azure.resourcemanager.mediaservices.models.LiveEventStreamEventLevel;
import com.azure.resourcemanager.mediaservices.models.LiveEventStreamEventType;
import java.io.IOException;
import java.time.OffsetDateTime;
import java.time.format.DateTimeFormatter;

/**
 * The live event stream event.
 */
@Fluent
public final class LiveEventStreamEventInner implements JsonSerializable {
    /*
     * The type of the stream event. Format: StreamEvent/{eventType}
     */
    private LiveEventStreamEventType eventType;

    /*
     * The time event raised.
     */
    private OffsetDateTime eventTime;

    /*
     * Event level.
     */
    private LiveEventStreamEventLevel eventLevel;

    /*
     * Event data based on event type.
     */
    private LiveEventStreamEventData data;

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

    /**
     * Get the eventType property: The type of the stream event. Format: StreamEvent/{eventType}.
     * 
     * @return the eventType value.
     */
    public LiveEventStreamEventType eventType() {
        return this.eventType;
    }

    /**
     * Set the eventType property: The type of the stream event. Format: StreamEvent/{eventType}.
     * 
     * @param eventType the eventType value to set.
     * @return the LiveEventStreamEventInner object itself.
     */
    public LiveEventStreamEventInner withEventType(LiveEventStreamEventType eventType) {
        this.eventType = eventType;
        return this;
    }

    /**
     * Get the eventTime property: The time event raised.
     * 
     * @return the eventTime value.
     */
    public OffsetDateTime eventTime() {
        return this.eventTime;
    }

    /**
     * Set the eventTime property: The time event raised.
     * 
     * @param eventTime the eventTime value to set.
     * @return the LiveEventStreamEventInner object itself.
     */
    public LiveEventStreamEventInner withEventTime(OffsetDateTime eventTime) {
        this.eventTime = eventTime;
        return this;
    }

    /**
     * Get the eventLevel property: Event level.
     * 
     * @return the eventLevel value.
     */
    public LiveEventStreamEventLevel eventLevel() {
        return this.eventLevel;
    }

    /**
     * Set the eventLevel property: Event level.
     * 
     * @param eventLevel the eventLevel value to set.
     * @return the LiveEventStreamEventInner object itself.
     */
    public LiveEventStreamEventInner withEventLevel(LiveEventStreamEventLevel eventLevel) {
        this.eventLevel = eventLevel;
        return this;
    }

    /**
     * Get the data property: Event data based on event type.
     * 
     * @return the data value.
     */
    public LiveEventStreamEventData data() {
        return this.data;
    }

    /**
     * Set the data property: Event data based on event type.
     * 
     * @param data the data value to set.
     * @return the LiveEventStreamEventInner object itself.
     */
    public LiveEventStreamEventInner withData(LiveEventStreamEventData data) {
        this.data = data;
        return this;
    }

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

    /**
     * {@inheritDoc}
     */
    @Override
    public JsonWriter toJson(JsonWriter jsonWriter) throws IOException {
        jsonWriter.writeStartObject();
        jsonWriter.writeStringField("eventType", this.eventType == null ? null : this.eventType.toString());
        jsonWriter.writeStringField("eventTime",
            this.eventTime == null ? null : DateTimeFormatter.ISO_OFFSET_DATE_TIME.format(this.eventTime));
        jsonWriter.writeStringField("eventLevel", this.eventLevel == null ? null : this.eventLevel.toString());
        jsonWriter.writeJsonField("data", this.data);
        return jsonWriter.writeEndObject();
    }

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

                if ("eventType".equals(fieldName)) {
                    deserializedLiveEventStreamEventInner.eventType
                        = LiveEventStreamEventType.fromString(reader.getString());
                } else if ("eventTime".equals(fieldName)) {
                    deserializedLiveEventStreamEventInner.eventTime = reader
                        .getNullable(nonNullReader -> CoreUtils.parseBestOffsetDateTime(nonNullReader.getString()));
                } else if ("eventLevel".equals(fieldName)) {
                    deserializedLiveEventStreamEventInner.eventLevel
                        = LiveEventStreamEventLevel.fromString(reader.getString());
                } else if ("data".equals(fieldName)) {
                    deserializedLiveEventStreamEventInner.data = LiveEventStreamEventData.fromJson(reader);
                } else {
                    reader.skipChildren();
                }
            }

            return deserializedLiveEventStreamEventInner;
        });
    }
}




© 2015 - 2024 Weber Informatics LLC | Privacy Policy