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

com.azure.resourcemanager.servicelinker.models.PermissionsMissingDryrunPrerequisiteResult Maven / Gradle / Ivy

// Copyright (c) Microsoft Corporation. All rights reserved.
// Licensed under the MIT License.
// Code generated by Microsoft (R) AutoRest Code Generator.

package com.azure.resourcemanager.servicelinker.models;

import com.azure.core.annotation.Fluent;
import com.azure.json.JsonReader;
import com.azure.json.JsonToken;
import com.azure.json.JsonWriter;
import java.io.IOException;
import java.util.List;

/**
 * The represent of missing permissions.
 */
@Fluent
public final class PermissionsMissingDryrunPrerequisiteResult extends DryrunPrerequisiteResult {
    /*
     * The type of dryrun result.
     */
    private DryrunPrerequisiteResultType type = DryrunPrerequisiteResultType.PERMISSIONS_MISSING;

    /*
     * The permission scope
     */
    private String scope;

    /*
     * The permission list
     */
    private List permissions;

    /*
     * The recommended role to resolve permissions missing
     */
    private String recommendedRole;

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

    /**
     * Get the type property: The type of dryrun result.
     * 
     * @return the type value.
     */
    @Override
    public DryrunPrerequisiteResultType type() {
        return this.type;
    }

    /**
     * Get the scope property: The permission scope.
     * 
     * @return the scope value.
     */
    public String scope() {
        return this.scope;
    }

    /**
     * Set the scope property: The permission scope.
     * 
     * @param scope the scope value to set.
     * @return the PermissionsMissingDryrunPrerequisiteResult object itself.
     */
    public PermissionsMissingDryrunPrerequisiteResult withScope(String scope) {
        this.scope = scope;
        return this;
    }

    /**
     * Get the permissions property: The permission list.
     * 
     * @return the permissions value.
     */
    public List permissions() {
        return this.permissions;
    }

    /**
     * Set the permissions property: The permission list.
     * 
     * @param permissions the permissions value to set.
     * @return the PermissionsMissingDryrunPrerequisiteResult object itself.
     */
    public PermissionsMissingDryrunPrerequisiteResult withPermissions(List permissions) {
        this.permissions = permissions;
        return this;
    }

    /**
     * Get the recommendedRole property: The recommended role to resolve permissions missing.
     * 
     * @return the recommendedRole value.
     */
    public String recommendedRole() {
        return this.recommendedRole;
    }

    /**
     * Set the recommendedRole property: The recommended role to resolve permissions missing.
     * 
     * @param recommendedRole the recommendedRole value to set.
     * @return the PermissionsMissingDryrunPrerequisiteResult object itself.
     */
    public PermissionsMissingDryrunPrerequisiteResult withRecommendedRole(String recommendedRole) {
        this.recommendedRole = recommendedRole;
        return this;
    }

    /**
     * Validates the instance.
     * 
     * @throws IllegalArgumentException thrown if the instance is not valid.
     */
    @Override
    public void validate() {
    }

    /**
     * {@inheritDoc}
     */
    @Override
    public JsonWriter toJson(JsonWriter jsonWriter) throws IOException {
        jsonWriter.writeStartObject();
        jsonWriter.writeStringField("type", this.type == null ? null : this.type.toString());
        jsonWriter.writeStringField("scope", this.scope);
        jsonWriter.writeArrayField("permissions", this.permissions, (writer, element) -> writer.writeString(element));
        jsonWriter.writeStringField("recommendedRole", this.recommendedRole);
        return jsonWriter.writeEndObject();
    }

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

                if ("type".equals(fieldName)) {
                    deserializedPermissionsMissingDryrunPrerequisiteResult.type
                        = DryrunPrerequisiteResultType.fromString(reader.getString());
                } else if ("scope".equals(fieldName)) {
                    deserializedPermissionsMissingDryrunPrerequisiteResult.scope = reader.getString();
                } else if ("permissions".equals(fieldName)) {
                    List permissions = reader.readArray(reader1 -> reader1.getString());
                    deserializedPermissionsMissingDryrunPrerequisiteResult.permissions = permissions;
                } else if ("recommendedRole".equals(fieldName)) {
                    deserializedPermissionsMissingDryrunPrerequisiteResult.recommendedRole = reader.getString();
                } else {
                    reader.skipChildren();
                }
            }

            return deserializedPermissionsMissingDryrunPrerequisiteResult;
        });
    }
}




© 2015 - 2024 Weber Informatics LLC | Privacy Policy