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

com.azure.security.keyvault.administration.implementation.models.RestoreOperationParameters Maven / Gradle / Ivy

There is a newer version: 4.6.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.security.keyvault.administration.implementation.models;

import com.azure.core.annotation.Immutable;
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.ArrayList;
import java.util.List;

/**
 * The RestoreOperationParameters model.
 */
@Immutable
public final class RestoreOperationParameters implements JsonSerializable {
    /*
     * The sasTokenParameters property.
     */
    private final SASTokenParameter sasTokenParameters;

    /*
     * The Folder name of the blob where the previous successful full backup was stored
     */
    private final String folderToRestore;

    /**
     * Creates an instance of RestoreOperationParameters class.
     * 
     * @param sasTokenParameters the sasTokenParameters value to set.
     * @param folderToRestore the folderToRestore value to set.
     */
    public RestoreOperationParameters(SASTokenParameter sasTokenParameters, String folderToRestore) {
        this.sasTokenParameters = sasTokenParameters;
        this.folderToRestore = folderToRestore;
    }

    /**
     * Get the sasTokenParameters property: The sasTokenParameters property.
     * 
     * @return the sasTokenParameters value.
     */
    public SASTokenParameter getSasTokenParameters() {
        return this.sasTokenParameters;
    }

    /**
     * Get the folderToRestore property: The Folder name of the blob where the previous successful full backup was
     * stored.
     * 
     * @return the folderToRestore value.
     */
    public String getFolderToRestore() {
        return this.folderToRestore;
    }

    @Override
    public JsonWriter toJson(JsonWriter jsonWriter) throws IOException {
        jsonWriter.writeStartObject();
        jsonWriter.writeJsonField("sasTokenParameters", this.sasTokenParameters);
        jsonWriter.writeStringField("folderToRestore", this.folderToRestore);
        return jsonWriter.writeEndObject();
    }

    /**
     * Reads an instance of RestoreOperationParameters from the JsonReader.
     * 
     * @param jsonReader The JsonReader being read.
     * @return An instance of RestoreOperationParameters if the JsonReader was pointing to an instance of it, or null if
     * it was pointing to JSON null.
     * @throws IllegalStateException If the deserialized JSON object was missing any required properties.
     * @throws IOException If an error occurs while reading the RestoreOperationParameters.
     */
    public static RestoreOperationParameters fromJson(JsonReader jsonReader) throws IOException {
        return jsonReader.readObject(reader -> {
            boolean sasTokenParametersFound = false;
            SASTokenParameter sasTokenParameters = null;
            boolean folderToRestoreFound = false;
            String folderToRestore = null;
            while (reader.nextToken() != JsonToken.END_OBJECT) {
                String fieldName = reader.getFieldName();
                reader.nextToken();

                if ("sasTokenParameters".equals(fieldName)) {
                    sasTokenParameters = SASTokenParameter.fromJson(reader);
                    sasTokenParametersFound = true;
                } else if ("folderToRestore".equals(fieldName)) {
                    folderToRestore = reader.getString();
                    folderToRestoreFound = true;
                } else {
                    reader.skipChildren();
                }
            }
            if (sasTokenParametersFound && folderToRestoreFound) {
                RestoreOperationParameters deserializedRestoreOperationParameters
                    = new RestoreOperationParameters(sasTokenParameters, folderToRestore);

                return deserializedRestoreOperationParameters;
            }
            List missingProperties = new ArrayList<>();
            if (!sasTokenParametersFound) {
                missingProperties.add("sasTokenParameters");
            }
            if (!folderToRestoreFound) {
                missingProperties.add("folderToRestore");
            }

            throw new IllegalStateException(
                "Missing required property/properties: " + String.join(", ", missingProperties));
        });
    }
}




© 2015 - 2024 Weber Informatics LLC | Privacy Policy