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

com.azure.resourcemanager.security.models.UserDefinedResourcesProperties 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.security.models;

import com.azure.core.annotation.Fluent;
import com.azure.core.util.logging.ClientLogger;
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;

/**
 * Properties of the IoT Security solution's user defined resources.
 */
@Fluent
public final class UserDefinedResourcesProperties implements JsonSerializable {
    /*
     * Azure Resource Graph query which represents the security solution's user defined resources. Required to start
     * with "where type != "Microsoft.Devices/IotHubs""
     */
    private String query;

    /*
     * List of Azure subscription ids on which the user defined resources query should be executed.
     */
    private List querySubscriptions;

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

    /**
     * Get the query property: Azure Resource Graph query which represents the security solution's user defined
     * resources. Required to start with "where type != "Microsoft.Devices/IotHubs"".
     * 
     * @return the query value.
     */
    public String query() {
        return this.query;
    }

    /**
     * Set the query property: Azure Resource Graph query which represents the security solution's user defined
     * resources. Required to start with "where type != "Microsoft.Devices/IotHubs"".
     * 
     * @param query the query value to set.
     * @return the UserDefinedResourcesProperties object itself.
     */
    public UserDefinedResourcesProperties withQuery(String query) {
        this.query = query;
        return this;
    }

    /**
     * Get the querySubscriptions property: List of Azure subscription ids on which the user defined resources query
     * should be executed.
     * 
     * @return the querySubscriptions value.
     */
    public List querySubscriptions() {
        return this.querySubscriptions;
    }

    /**
     * Set the querySubscriptions property: List of Azure subscription ids on which the user defined resources query
     * should be executed.
     * 
     * @param querySubscriptions the querySubscriptions value to set.
     * @return the UserDefinedResourcesProperties object itself.
     */
    public UserDefinedResourcesProperties withQuerySubscriptions(List querySubscriptions) {
        this.querySubscriptions = querySubscriptions;
        return this;
    }

    /**
     * Validates the instance.
     * 
     * @throws IllegalArgumentException thrown if the instance is not valid.
     */
    public void validate() {
        if (query() == null) {
            throw LOGGER.atError()
                .log(new IllegalArgumentException(
                    "Missing required property query in model UserDefinedResourcesProperties"));
        }
        if (querySubscriptions() == null) {
            throw LOGGER.atError()
                .log(new IllegalArgumentException(
                    "Missing required property querySubscriptions in model UserDefinedResourcesProperties"));
        }
    }

    private static final ClientLogger LOGGER = new ClientLogger(UserDefinedResourcesProperties.class);

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

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

                if ("query".equals(fieldName)) {
                    deserializedUserDefinedResourcesProperties.query = reader.getString();
                } else if ("querySubscriptions".equals(fieldName)) {
                    List querySubscriptions = reader.readArray(reader1 -> reader1.getString());
                    deserializedUserDefinedResourcesProperties.querySubscriptions = querySubscriptions;
                } else {
                    reader.skipChildren();
                }
            }

            return deserializedUserDefinedResourcesProperties;
        });
    }
}




© 2015 - 2025 Weber Informatics LLC | Privacy Policy