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

com.azure.messaging.eventgrid.systemevents.AvsClusterEventData 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.json.JsonReader;
import com.azure.json.JsonSerializable;
import com.azure.json.JsonToken;
import com.azure.json.JsonWriter;
import java.io.IOException;
import java.util.List;

/**
 * Schema of the Data property of an EventGridEvent for Microsoft.AVS/clusters events.
 */
@Fluent
public class AvsClusterEventData implements JsonSerializable {
    /*
     * Id of the operation that caused this event.
     */
    private String operationId;

    /*
     * Hosts added to the cluster in this event, if any.
     */
    private List addedHostNames;

    /*
     * Hosts removed to the cluster in this event, if any.
     */
    private List removedHostNames;

    /*
     * Hosts in Maintenance mode in the cluster, if any.
     */
    private List inMaintenanceHostNames;

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

    /**
     * Get the operationId property: Id of the operation that caused this event.
     * 
     * @return the operationId value.
     */
    public String getOperationId() {
        return this.operationId;
    }

    /**
     * Set the operationId property: Id of the operation that caused this event.
     * 
     * @param operationId the operationId value to set.
     * @return the AvsClusterEventData object itself.
     */
    public AvsClusterEventData setOperationId(String operationId) {
        this.operationId = operationId;
        return this;
    }

    /**
     * Get the addedHostNames property: Hosts added to the cluster in this event, if any.
     * 
     * @return the addedHostNames value.
     */
    public List getAddedHostNames() {
        return this.addedHostNames;
    }

    /**
     * Set the addedHostNames property: Hosts added to the cluster in this event, if any.
     * 
     * @param addedHostNames the addedHostNames value to set.
     * @return the AvsClusterEventData object itself.
     */
    public AvsClusterEventData setAddedHostNames(List addedHostNames) {
        this.addedHostNames = addedHostNames;
        return this;
    }

    /**
     * Get the removedHostNames property: Hosts removed to the cluster in this event, if any.
     * 
     * @return the removedHostNames value.
     */
    public List getRemovedHostNames() {
        return this.removedHostNames;
    }

    /**
     * Set the removedHostNames property: Hosts removed to the cluster in this event, if any.
     * 
     * @param removedHostNames the removedHostNames value to set.
     * @return the AvsClusterEventData object itself.
     */
    public AvsClusterEventData setRemovedHostNames(List removedHostNames) {
        this.removedHostNames = removedHostNames;
        return this;
    }

    /**
     * Get the inMaintenanceHostNames property: Hosts in Maintenance mode in the cluster, if any.
     * 
     * @return the inMaintenanceHostNames value.
     */
    public List getInMaintenanceHostNames() {
        return this.inMaintenanceHostNames;
    }

    /**
     * Set the inMaintenanceHostNames property: Hosts in Maintenance mode in the cluster, if any.
     * 
     * @param inMaintenanceHostNames the inMaintenanceHostNames value to set.
     * @return the AvsClusterEventData object itself.
     */
    public AvsClusterEventData setInMaintenanceHostNames(List inMaintenanceHostNames) {
        this.inMaintenanceHostNames = inMaintenanceHostNames;
        return this;
    }

    /**
     * {@inheritDoc}
     */
    @Override
    public JsonWriter toJson(JsonWriter jsonWriter) throws IOException {
        jsonWriter.writeStartObject();
        jsonWriter.writeStringField("operationId", this.operationId);
        jsonWriter.writeArrayField("addedHostNames", this.addedHostNames,
            (writer, element) -> writer.writeString(element));
        jsonWriter.writeArrayField("removedHostNames", this.removedHostNames,
            (writer, element) -> writer.writeString(element));
        jsonWriter.writeArrayField("inMaintenanceHostNames", this.inMaintenanceHostNames,
            (writer, element) -> writer.writeString(element));
        return jsonWriter.writeEndObject();
    }

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

                if ("operationId".equals(fieldName)) {
                    deserializedAvsClusterEventData.operationId = reader.getString();
                } else if ("addedHostNames".equals(fieldName)) {
                    List addedHostNames = reader.readArray(reader1 -> reader1.getString());
                    deserializedAvsClusterEventData.addedHostNames = addedHostNames;
                } else if ("removedHostNames".equals(fieldName)) {
                    List removedHostNames = reader.readArray(reader1 -> reader1.getString());
                    deserializedAvsClusterEventData.removedHostNames = removedHostNames;
                } else if ("inMaintenanceHostNames".equals(fieldName)) {
                    List inMaintenanceHostNames = reader.readArray(reader1 -> reader1.getString());
                    deserializedAvsClusterEventData.inMaintenanceHostNames = inMaintenanceHostNames;
                } else {
                    reader.skipChildren();
                }
            }

            return deserializedAvsClusterEventData;
        });
    }
}




© 2015 - 2024 Weber Informatics LLC | Privacy Policy