com.azure.resourcemanager.hdinsight.fluent.models.AsyncOperationResultInner Maven / Gradle / Ivy
Go to download
Show more of this group Show more artifacts with this name
Show all versions of azure-resourcemanager-hdinsight Show documentation
Show all versions of azure-resourcemanager-hdinsight Show documentation
This package contains Microsoft Azure SDK for HDInsight Management SDK. For documentation on how to use this package, please see https://aka.ms/azsdk/java/mgmt. HDInsight Management Client. Package tag package-2024-08-preview.
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.hdinsight.fluent.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.hdinsight.models.AsyncOperationState;
import com.azure.resourcemanager.hdinsight.models.Errors;
import java.io.IOException;
/**
* The azure async operation response.
*/
@Fluent
public final class AsyncOperationResultInner implements JsonSerializable {
/*
* The async operation state.
*/
private AsyncOperationState status;
/*
* The operation error information.
*/
private Errors error;
/**
* Creates an instance of AsyncOperationResultInner class.
*/
public AsyncOperationResultInner() {
}
/**
* Get the status property: The async operation state.
*
* @return the status value.
*/
public AsyncOperationState status() {
return this.status;
}
/**
* Set the status property: The async operation state.
*
* @param status the status value to set.
* @return the AsyncOperationResultInner object itself.
*/
public AsyncOperationResultInner withStatus(AsyncOperationState status) {
this.status = status;
return this;
}
/**
* Get the error property: The operation error information.
*
* @return the error value.
*/
public Errors error() {
return this.error;
}
/**
* Set the error property: The operation error information.
*
* @param error the error value to set.
* @return the AsyncOperationResultInner object itself.
*/
public AsyncOperationResultInner withError(Errors error) {
this.error = error;
return this;
}
/**
* Validates the instance.
*
* @throws IllegalArgumentException thrown if the instance is not valid.
*/
public void validate() {
if (error() != null) {
error().validate();
}
}
/**
* {@inheritDoc}
*/
@Override
public JsonWriter toJson(JsonWriter jsonWriter) throws IOException {
jsonWriter.writeStartObject();
jsonWriter.writeStringField("status", this.status == null ? null : this.status.toString());
jsonWriter.writeJsonField("error", this.error);
return jsonWriter.writeEndObject();
}
/**
* Reads an instance of AsyncOperationResultInner from the JsonReader.
*
* @param jsonReader The JsonReader being read.
* @return An instance of AsyncOperationResultInner 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 AsyncOperationResultInner.
*/
public static AsyncOperationResultInner fromJson(JsonReader jsonReader) throws IOException {
return jsonReader.readObject(reader -> {
AsyncOperationResultInner deserializedAsyncOperationResultInner = new AsyncOperationResultInner();
while (reader.nextToken() != JsonToken.END_OBJECT) {
String fieldName = reader.getFieldName();
reader.nextToken();
if ("status".equals(fieldName)) {
deserializedAsyncOperationResultInner.status = AsyncOperationState.fromString(reader.getString());
} else if ("error".equals(fieldName)) {
deserializedAsyncOperationResultInner.error = Errors.fromJson(reader);
} else {
reader.skipChildren();
}
}
return deserializedAsyncOperationResultInner;
});
}
}