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

com.azure.resourcemanager.netapp.models.VolumePropertiesDataProtection Maven / Gradle / Ivy

Go to download

This package contains Microsoft Azure SDK for NetAppFiles Management SDK. For documentation on how to use this package, please see https://aka.ms/azsdk/java/mgmt. Microsoft NetApp Files Azure Resource Provider specification. Package tag package-2024-03.

There is a newer version: 1.4.0
Show 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.netapp.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;

/**
 * DataProtection
 * 
 * DataProtection type volumes include an object containing details of the replication.
 */
@Fluent
public final class VolumePropertiesDataProtection implements JsonSerializable {
    /*
     * Backup Properties
     */
    private VolumeBackupProperties backup;

    /*
     * Replication properties
     */
    private ReplicationObject replication;

    /*
     * Snapshot properties.
     */
    private VolumeSnapshotProperties snapshot;

    /*
     * VolumeRelocation properties
     */
    private VolumeRelocationProperties volumeRelocation;

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

    /**
     * Get the backup property: Backup Properties.
     * 
     * @return the backup value.
     */
    public VolumeBackupProperties backup() {
        return this.backup;
    }

    /**
     * Set the backup property: Backup Properties.
     * 
     * @param backup the backup value to set.
     * @return the VolumePropertiesDataProtection object itself.
     */
    public VolumePropertiesDataProtection withBackup(VolumeBackupProperties backup) {
        this.backup = backup;
        return this;
    }

    /**
     * Get the replication property: Replication properties.
     * 
     * @return the replication value.
     */
    public ReplicationObject replication() {
        return this.replication;
    }

    /**
     * Set the replication property: Replication properties.
     * 
     * @param replication the replication value to set.
     * @return the VolumePropertiesDataProtection object itself.
     */
    public VolumePropertiesDataProtection withReplication(ReplicationObject replication) {
        this.replication = replication;
        return this;
    }

    /**
     * Get the snapshot property: Snapshot properties.
     * 
     * @return the snapshot value.
     */
    public VolumeSnapshotProperties snapshot() {
        return this.snapshot;
    }

    /**
     * Set the snapshot property: Snapshot properties.
     * 
     * @param snapshot the snapshot value to set.
     * @return the VolumePropertiesDataProtection object itself.
     */
    public VolumePropertiesDataProtection withSnapshot(VolumeSnapshotProperties snapshot) {
        this.snapshot = snapshot;
        return this;
    }

    /**
     * Get the volumeRelocation property: VolumeRelocation properties.
     * 
     * @return the volumeRelocation value.
     */
    public VolumeRelocationProperties volumeRelocation() {
        return this.volumeRelocation;
    }

    /**
     * Set the volumeRelocation property: VolumeRelocation properties.
     * 
     * @param volumeRelocation the volumeRelocation value to set.
     * @return the VolumePropertiesDataProtection object itself.
     */
    public VolumePropertiesDataProtection withVolumeRelocation(VolumeRelocationProperties volumeRelocation) {
        this.volumeRelocation = volumeRelocation;
        return this;
    }

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

    /**
     * {@inheritDoc}
     */
    @Override
    public JsonWriter toJson(JsonWriter jsonWriter) throws IOException {
        jsonWriter.writeStartObject();
        jsonWriter.writeJsonField("backup", this.backup);
        jsonWriter.writeJsonField("replication", this.replication);
        jsonWriter.writeJsonField("snapshot", this.snapshot);
        jsonWriter.writeJsonField("volumeRelocation", this.volumeRelocation);
        return jsonWriter.writeEndObject();
    }

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

                if ("backup".equals(fieldName)) {
                    deserializedVolumePropertiesDataProtection.backup = VolumeBackupProperties.fromJson(reader);
                } else if ("replication".equals(fieldName)) {
                    deserializedVolumePropertiesDataProtection.replication = ReplicationObject.fromJson(reader);
                } else if ("snapshot".equals(fieldName)) {
                    deserializedVolumePropertiesDataProtection.snapshot = VolumeSnapshotProperties.fromJson(reader);
                } else if ("volumeRelocation".equals(fieldName)) {
                    deserializedVolumePropertiesDataProtection.volumeRelocation
                        = VolumeRelocationProperties.fromJson(reader);
                } else {
                    reader.skipChildren();
                }
            }

            return deserializedVolumePropertiesDataProtection;
        });
    }
}




© 2015 - 2024 Weber Informatics LLC | Privacy Policy