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

com.azure.resourcemanager.policyinsights.models.SummaryResults 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.policyinsights.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;

/**
 * Compliance summary on a particular summary level.
 */
@Fluent
public final class SummaryResults implements JsonSerializable {
    /*
     * HTTP POST URI for queryResults action on Microsoft.PolicyInsights to retrieve raw results for the compliance
     * summary. This property will not be available by default in future API versions, but could be queried explicitly.
     */
    private String queryResultsUri;

    /*
     * Number of non-compliant resources.
     */
    private Integer nonCompliantResources;

    /*
     * Number of non-compliant policies.
     */
    private Integer nonCompliantPolicies;

    /*
     * The resources summary at this level.
     */
    private List resourceDetails;

    /*
     * The policy artifact summary at this level. For query scope level, it represents policy assignment summary. For
     * policy assignment level, it represents policy definitions summary.
     */
    private List policyDetails;

    /*
     * The policy definition group summary at this level.
     */
    private List policyGroupDetails;

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

    /**
     * Get the queryResultsUri property: HTTP POST URI for queryResults action on Microsoft.PolicyInsights to retrieve
     * raw results for the compliance summary. This property will not be available by default in future API versions,
     * but could be queried explicitly.
     * 
     * @return the queryResultsUri value.
     */
    public String queryResultsUri() {
        return this.queryResultsUri;
    }

    /**
     * Set the queryResultsUri property: HTTP POST URI for queryResults action on Microsoft.PolicyInsights to retrieve
     * raw results for the compliance summary. This property will not be available by default in future API versions,
     * but could be queried explicitly.
     * 
     * @param queryResultsUri the queryResultsUri value to set.
     * @return the SummaryResults object itself.
     */
    public SummaryResults withQueryResultsUri(String queryResultsUri) {
        this.queryResultsUri = queryResultsUri;
        return this;
    }

    /**
     * Get the nonCompliantResources property: Number of non-compliant resources.
     * 
     * @return the nonCompliantResources value.
     */
    public Integer nonCompliantResources() {
        return this.nonCompliantResources;
    }

    /**
     * Set the nonCompliantResources property: Number of non-compliant resources.
     * 
     * @param nonCompliantResources the nonCompliantResources value to set.
     * @return the SummaryResults object itself.
     */
    public SummaryResults withNonCompliantResources(Integer nonCompliantResources) {
        this.nonCompliantResources = nonCompliantResources;
        return this;
    }

    /**
     * Get the nonCompliantPolicies property: Number of non-compliant policies.
     * 
     * @return the nonCompliantPolicies value.
     */
    public Integer nonCompliantPolicies() {
        return this.nonCompliantPolicies;
    }

    /**
     * Set the nonCompliantPolicies property: Number of non-compliant policies.
     * 
     * @param nonCompliantPolicies the nonCompliantPolicies value to set.
     * @return the SummaryResults object itself.
     */
    public SummaryResults withNonCompliantPolicies(Integer nonCompliantPolicies) {
        this.nonCompliantPolicies = nonCompliantPolicies;
        return this;
    }

    /**
     * Get the resourceDetails property: The resources summary at this level.
     * 
     * @return the resourceDetails value.
     */
    public List resourceDetails() {
        return this.resourceDetails;
    }

    /**
     * Set the resourceDetails property: The resources summary at this level.
     * 
     * @param resourceDetails the resourceDetails value to set.
     * @return the SummaryResults object itself.
     */
    public SummaryResults withResourceDetails(List resourceDetails) {
        this.resourceDetails = resourceDetails;
        return this;
    }

    /**
     * Get the policyDetails property: The policy artifact summary at this level. For query scope level, it represents
     * policy assignment summary. For policy assignment level, it represents policy definitions summary.
     * 
     * @return the policyDetails value.
     */
    public List policyDetails() {
        return this.policyDetails;
    }

    /**
     * Set the policyDetails property: The policy artifact summary at this level. For query scope level, it represents
     * policy assignment summary. For policy assignment level, it represents policy definitions summary.
     * 
     * @param policyDetails the policyDetails value to set.
     * @return the SummaryResults object itself.
     */
    public SummaryResults withPolicyDetails(List policyDetails) {
        this.policyDetails = policyDetails;
        return this;
    }

    /**
     * Get the policyGroupDetails property: The policy definition group summary at this level.
     * 
     * @return the policyGroupDetails value.
     */
    public List policyGroupDetails() {
        return this.policyGroupDetails;
    }

    /**
     * Set the policyGroupDetails property: The policy definition group summary at this level.
     * 
     * @param policyGroupDetails the policyGroupDetails value to set.
     * @return the SummaryResults object itself.
     */
    public SummaryResults withPolicyGroupDetails(List policyGroupDetails) {
        this.policyGroupDetails = policyGroupDetails;
        return this;
    }

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

    /**
     * {@inheritDoc}
     */
    @Override
    public JsonWriter toJson(JsonWriter jsonWriter) throws IOException {
        jsonWriter.writeStartObject();
        jsonWriter.writeStringField("queryResultsUri", this.queryResultsUri);
        jsonWriter.writeNumberField("nonCompliantResources", this.nonCompliantResources);
        jsonWriter.writeNumberField("nonCompliantPolicies", this.nonCompliantPolicies);
        jsonWriter.writeArrayField("resourceDetails", this.resourceDetails,
            (writer, element) -> writer.writeJson(element));
        jsonWriter.writeArrayField("policyDetails", this.policyDetails, (writer, element) -> writer.writeJson(element));
        jsonWriter.writeArrayField("policyGroupDetails", this.policyGroupDetails,
            (writer, element) -> writer.writeJson(element));
        return jsonWriter.writeEndObject();
    }

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

                if ("queryResultsUri".equals(fieldName)) {
                    deserializedSummaryResults.queryResultsUri = reader.getString();
                } else if ("nonCompliantResources".equals(fieldName)) {
                    deserializedSummaryResults.nonCompliantResources = reader.getNullable(JsonReader::getInt);
                } else if ("nonCompliantPolicies".equals(fieldName)) {
                    deserializedSummaryResults.nonCompliantPolicies = reader.getNullable(JsonReader::getInt);
                } else if ("resourceDetails".equals(fieldName)) {
                    List resourceDetails
                        = reader.readArray(reader1 -> ComplianceDetail.fromJson(reader1));
                    deserializedSummaryResults.resourceDetails = resourceDetails;
                } else if ("policyDetails".equals(fieldName)) {
                    List policyDetails
                        = reader.readArray(reader1 -> ComplianceDetail.fromJson(reader1));
                    deserializedSummaryResults.policyDetails = policyDetails;
                } else if ("policyGroupDetails".equals(fieldName)) {
                    List policyGroupDetails
                        = reader.readArray(reader1 -> ComplianceDetail.fromJson(reader1));
                    deserializedSummaryResults.policyGroupDetails = policyGroupDetails;
                } else {
                    reader.skipChildren();
                }
            }

            return deserializedSummaryResults;
        });
    }
}




© 2015 - 2025 Weber Informatics LLC | Privacy Policy