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

com.azure.security.keyvault.administration.implementation.models.SelectiveKeyRestoreOperationParameters 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 SelectiveKeyRestoreOperationParameters model.
 */
@Immutable
public final class SelectiveKeyRestoreOperationParameters
    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 folder;

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

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

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

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

    /**
     * Reads an instance of SelectiveKeyRestoreOperationParameters from the JsonReader.
     * 
     * @param jsonReader The JsonReader being read.
     * @return An instance of SelectiveKeyRestoreOperationParameters 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 SelectiveKeyRestoreOperationParameters.
     */
    public static SelectiveKeyRestoreOperationParameters fromJson(JsonReader jsonReader) throws IOException {
        return jsonReader.readObject(reader -> {
            boolean sasTokenParametersFound = false;
            SASTokenParameter sasTokenParameters = null;
            boolean folderFound = false;
            String folder = 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 ("folder".equals(fieldName)) {
                    folder = reader.getString();
                    folderFound = true;
                } else {
                    reader.skipChildren();
                }
            }
            if (sasTokenParametersFound && folderFound) {
                SelectiveKeyRestoreOperationParameters deserializedSelectiveKeyRestoreOperationParameters
                    = new SelectiveKeyRestoreOperationParameters(sasTokenParameters, folder);

                return deserializedSelectiveKeyRestoreOperationParameters;
            }
            List missingProperties = new ArrayList<>();
            if (!sasTokenParametersFound) {
                missingProperties.add("sasTokenParameters");
            }
            if (!folderFound) {
                missingProperties.add("folder");
            }

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




© 2015 - 2024 Weber Informatics LLC | Privacy Policy