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

com.azure.security.keyvault.administration.implementation.models.RoleAssignmentCreateParameters 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;

/**
 * Role assignment create parameters.
 */
@Immutable
public final class RoleAssignmentCreateParameters implements JsonSerializable {
    /*
     * Role assignment properties.
     */
    private final RoleAssignmentProperties properties;

    /**
     * Creates an instance of RoleAssignmentCreateParameters class.
     * 
     * @param properties the properties value to set.
     */
    public RoleAssignmentCreateParameters(RoleAssignmentProperties properties) {
        this.properties = properties;
    }

    /**
     * Get the properties property: Role assignment properties.
     * 
     * @return the properties value.
     */
    public RoleAssignmentProperties getProperties() {
        return this.properties;
    }

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

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

                if ("properties".equals(fieldName)) {
                    properties = RoleAssignmentProperties.fromJson(reader);
                    propertiesFound = true;
                } else {
                    reader.skipChildren();
                }
            }
            if (propertiesFound) {
                RoleAssignmentCreateParameters deserializedRoleAssignmentCreateParameters
                    = new RoleAssignmentCreateParameters(properties);

                return deserializedRoleAssignmentCreateParameters;
            }
            List missingProperties = new ArrayList<>();
            if (!propertiesFound) {
                missingProperties.add("properties");
            }

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




© 2015 - 2024 Weber Informatics LLC | Privacy Policy