com.azure.resourcemanager.logz.models.VMHostUpdateRequest Maven / Gradle / Ivy
// Copyright (c) Microsoft Corporation. All rights reserved.
// Licensed under the MIT License.
// Code generated by Microsoft (R) AutoRest Code Generator.
package com.azure.resourcemanager.logz.models;
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 com.azure.resourcemanager.logz.fluent.models.VMResourcesInner;
import java.io.IOException;
import java.util.List;
/**
* Request of a list VM Host Update Operation.
*/
@Fluent
public final class VMHostUpdateRequest implements JsonSerializable {
/*
* Request of a list vm host update operation.
*/
private List vmResourceIds;
/*
* Specifies the state of the operation - install/ delete.
*/
private VMHostUpdateStates state;
/**
* Creates an instance of VMHostUpdateRequest class.
*/
public VMHostUpdateRequest() {
}
/**
* Get the vmResourceIds property: Request of a list vm host update operation.
*
* @return the vmResourceIds value.
*/
public List vmResourceIds() {
return this.vmResourceIds;
}
/**
* Set the vmResourceIds property: Request of a list vm host update operation.
*
* @param vmResourceIds the vmResourceIds value to set.
* @return the VMHostUpdateRequest object itself.
*/
public VMHostUpdateRequest withVmResourceIds(List vmResourceIds) {
this.vmResourceIds = vmResourceIds;
return this;
}
/**
* Get the state property: Specifies the state of the operation - install/ delete.
*
* @return the state value.
*/
public VMHostUpdateStates state() {
return this.state;
}
/**
* Set the state property: Specifies the state of the operation - install/ delete.
*
* @param state the state value to set.
* @return the VMHostUpdateRequest object itself.
*/
public VMHostUpdateRequest withState(VMHostUpdateStates state) {
this.state = state;
return this;
}
/**
* Validates the instance.
*
* @throws IllegalArgumentException thrown if the instance is not valid.
*/
public void validate() {
if (vmResourceIds() != null) {
vmResourceIds().forEach(e -> e.validate());
}
}
/**
* {@inheritDoc}
*/
@Override
public JsonWriter toJson(JsonWriter jsonWriter) throws IOException {
jsonWriter.writeStartObject();
jsonWriter.writeArrayField("vmResourceIds", this.vmResourceIds, (writer, element) -> writer.writeJson(element));
jsonWriter.writeStringField("state", this.state == null ? null : this.state.toString());
return jsonWriter.writeEndObject();
}
/**
* Reads an instance of VMHostUpdateRequest from the JsonReader.
*
* @param jsonReader The JsonReader being read.
* @return An instance of VMHostUpdateRequest 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 VMHostUpdateRequest.
*/
public static VMHostUpdateRequest fromJson(JsonReader jsonReader) throws IOException {
return jsonReader.readObject(reader -> {
VMHostUpdateRequest deserializedVMHostUpdateRequest = new VMHostUpdateRequest();
while (reader.nextToken() != JsonToken.END_OBJECT) {
String fieldName = reader.getFieldName();
reader.nextToken();
if ("vmResourceIds".equals(fieldName)) {
List vmResourceIds
= reader.readArray(reader1 -> VMResourcesInner.fromJson(reader1));
deserializedVMHostUpdateRequest.vmResourceIds = vmResourceIds;
} else if ("state".equals(fieldName)) {
deserializedVMHostUpdateRequest.state = VMHostUpdateStates.fromString(reader.getString());
} else {
reader.skipChildren();
}
}
return deserializedVMHostUpdateRequest;
});
}
}
© 2015 - 2025 Weber Informatics LLC | Privacy Policy