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

com.azure.resourcemanager.dataprotection.models.ProtectionStatusDetails Maven / Gradle / Ivy

Go to download

This package contains Microsoft Azure SDK for DataProtection Management SDK. For documentation on how to use this package, please see https://aka.ms/azsdk/java/mgmt. Open API 2.0 Specs for Azure Data Protection service. Package tag package-2024-04.

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.dataprotection.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 java.io.IOException;

/**
 * ProtectionStatusDetails
 * 
 * Protection status details.
 */
@Fluent
public final class ProtectionStatusDetails implements JsonSerializable {
    /*
     * Specifies the protection status error of the resource
     */
    private UserFacingError errorDetails;

    /*
     * Specifies the protection status of the resource
     */
    private Status status;

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

    /**
     * Get the errorDetails property: Specifies the protection status error of the resource.
     * 
     * @return the errorDetails value.
     */
    public UserFacingError errorDetails() {
        return this.errorDetails;
    }

    /**
     * Set the errorDetails property: Specifies the protection status error of the resource.
     * 
     * @param errorDetails the errorDetails value to set.
     * @return the ProtectionStatusDetails object itself.
     */
    public ProtectionStatusDetails withErrorDetails(UserFacingError errorDetails) {
        this.errorDetails = errorDetails;
        return this;
    }

    /**
     * Get the status property: Specifies the protection status of the resource.
     * 
     * @return the status value.
     */
    public Status status() {
        return this.status;
    }

    /**
     * Set the status property: Specifies the protection status of the resource.
     * 
     * @param status the status value to set.
     * @return the ProtectionStatusDetails object itself.
     */
    public ProtectionStatusDetails withStatus(Status status) {
        this.status = status;
        return this;
    }

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

    /**
     * {@inheritDoc}
     */
    @Override
    public JsonWriter toJson(JsonWriter jsonWriter) throws IOException {
        jsonWriter.writeStartObject();
        jsonWriter.writeJsonField("errorDetails", this.errorDetails);
        jsonWriter.writeStringField("status", this.status == null ? null : this.status.toString());
        return jsonWriter.writeEndObject();
    }

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

                if ("errorDetails".equals(fieldName)) {
                    deserializedProtectionStatusDetails.errorDetails = UserFacingError.fromJson(reader);
                } else if ("status".equals(fieldName)) {
                    deserializedProtectionStatusDetails.status = Status.fromString(reader.getString());
                } else {
                    reader.skipChildren();
                }
            }

            return deserializedProtectionStatusDetails;
        });
    }
}




© 2015 - 2024 Weber Informatics LLC | Privacy Policy