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

com.azure.resourcemanager.securityinsights.models.Permissions Maven / Gradle / Ivy

Go to download

This package contains Microsoft Azure SDK for SecurityInsights Management SDK. For documentation on how to use this package, please see https://aka.ms/azsdk/java/mgmt. API spec for Microsoft.SecurityInsights (Azure Security Insights) resource provider. Package tag package-preview-2022-09.

The 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.securityinsights.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;
import java.util.List;

/**
 * Permissions required for the connector.
 */
@Fluent
public final class Permissions implements JsonSerializable {
    /*
     * Resource provider permissions required for the connector
     */
    private List resourceProvider;

    /*
     * Customs permissions required for the connector
     */
    private List customs;

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

    /**
     * Get the resourceProvider property: Resource provider permissions required for the connector.
     * 
     * @return the resourceProvider value.
     */
    public List resourceProvider() {
        return this.resourceProvider;
    }

    /**
     * Set the resourceProvider property: Resource provider permissions required for the connector.
     * 
     * @param resourceProvider the resourceProvider value to set.
     * @return the Permissions object itself.
     */
    public Permissions withResourceProvider(List resourceProvider) {
        this.resourceProvider = resourceProvider;
        return this;
    }

    /**
     * Get the customs property: Customs permissions required for the connector.
     * 
     * @return the customs value.
     */
    public List customs() {
        return this.customs;
    }

    /**
     * Set the customs property: Customs permissions required for the connector.
     * 
     * @param customs the customs value to set.
     * @return the Permissions object itself.
     */
    public Permissions withCustoms(List customs) {
        this.customs = customs;
        return this;
    }

    /**
     * Validates the instance.
     * 
     * @throws IllegalArgumentException thrown if the instance is not valid.
     */
    public void validate() {
        if (resourceProvider() != null) {
            resourceProvider().forEach(e -> e.validate());
        }
        if (customs() != null) {
            customs().forEach(e -> e.validate());
        }
    }

    /**
     * {@inheritDoc}
     */
    @Override
    public JsonWriter toJson(JsonWriter jsonWriter) throws IOException {
        jsonWriter.writeStartObject();
        jsonWriter.writeArrayField("resourceProvider", this.resourceProvider,
            (writer, element) -> writer.writeJson(element));
        jsonWriter.writeArrayField("customs", this.customs, (writer, element) -> writer.writeJson(element));
        return jsonWriter.writeEndObject();
    }

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

                if ("resourceProvider".equals(fieldName)) {
                    List resourceProvider
                        = reader.readArray(reader1 -> PermissionsResourceProviderItem.fromJson(reader1));
                    deserializedPermissions.resourceProvider = resourceProvider;
                } else if ("customs".equals(fieldName)) {
                    List customs
                        = reader.readArray(reader1 -> PermissionsCustomsItem.fromJson(reader1));
                    deserializedPermissions.customs = customs;
                } else {
                    reader.skipChildren();
                }
            }

            return deserializedPermissions;
        });
    }
}




© 2015 - 2024 Weber Informatics LLC | Privacy Policy