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

com.azure.messaging.eventgrid.systemevents.SignalRServiceClientConnectionConnectedEventData 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.SignalRService.ClientConnectionConnected event.
 */
@Fluent
public final class SignalRServiceClientConnectionConnectedEventData
    implements JsonSerializable {
    /*
     * The time at which the event occurred.
     */
    private OffsetDateTime timestamp;

    /*
     * The hub of connected client connection.
     */
    private String hubName;

    /*
     * The connection Id of connected client connection.
     */
    private String connectionId;

    /*
     * The user Id of connected client connection.
     */
    private String userId;

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

    /**
     * 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 SignalRServiceClientConnectionConnectedEventData object itself.
     */
    public SignalRServiceClientConnectionConnectedEventData setTimestamp(OffsetDateTime timestamp) {
        this.timestamp = timestamp;
        return this;
    }

    /**
     * Get the hubName property: The hub of connected client connection.
     * 
     * @return the hubName value.
     */
    public String getHubName() {
        return this.hubName;
    }

    /**
     * Set the hubName property: The hub of connected client connection.
     * 
     * @param hubName the hubName value to set.
     * @return the SignalRServiceClientConnectionConnectedEventData object itself.
     */
    public SignalRServiceClientConnectionConnectedEventData setHubName(String hubName) {
        this.hubName = hubName;
        return this;
    }

    /**
     * Get the connectionId property: The connection Id of connected client connection.
     * 
     * @return the connectionId value.
     */
    public String getConnectionId() {
        return this.connectionId;
    }

    /**
     * Set the connectionId property: The connection Id of connected client connection.
     * 
     * @param connectionId the connectionId value to set.
     * @return the SignalRServiceClientConnectionConnectedEventData object itself.
     */
    public SignalRServiceClientConnectionConnectedEventData setConnectionId(String connectionId) {
        this.connectionId = connectionId;
        return this;
    }

    /**
     * Get the userId property: The user Id of connected client connection.
     * 
     * @return the userId value.
     */
    public String getUserId() {
        return this.userId;
    }

    /**
     * Set the userId property: The user Id of connected client connection.
     * 
     * @param userId the userId value to set.
     * @return the SignalRServiceClientConnectionConnectedEventData object itself.
     */
    public SignalRServiceClientConnectionConnectedEventData setUserId(String userId) {
        this.userId = userId;
        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("hubName", this.hubName);
        jsonWriter.writeStringField("connectionId", this.connectionId);
        jsonWriter.writeStringField("userId", this.userId);
        return jsonWriter.writeEndObject();
    }

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

                if ("timestamp".equals(fieldName)) {
                    deserializedSignalRServiceClientConnectionConnectedEventData.timestamp = reader
                        .getNullable(nonNullReader -> CoreUtils.parseBestOffsetDateTime(nonNullReader.getString()));
                } else if ("hubName".equals(fieldName)) {
                    deserializedSignalRServiceClientConnectionConnectedEventData.hubName = reader.getString();
                } else if ("connectionId".equals(fieldName)) {
                    deserializedSignalRServiceClientConnectionConnectedEventData.connectionId = reader.getString();
                } else if ("userId".equals(fieldName)) {
                    deserializedSignalRServiceClientConnectionConnectedEventData.userId = reader.getString();
                } else {
                    reader.skipChildren();
                }
            }

            return deserializedSignalRServiceClientConnectionConnectedEventData;
        });
    }
}




© 2015 - 2024 Weber Informatics LLC | Privacy Policy