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

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

/**
 * Summary results.
 */
@Fluent
public final class Summary implements JsonSerializable {
    /*
     * OData entity ID; always set to null since summaries do not have an entity ID.
     */
    private String odataId;

    /*
     * OData context string; used by OData clients to resolve type information based on metadata.
     */
    private String odataContext;

    /*
     * Compliance summary for all policy assignments.
     */
    private SummaryResults results;

    /*
     * Policy assignments summary.
     */
    private List policyAssignments;

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

    /**
     * Get the odataId property: OData entity ID; always set to null since summaries do not have an entity ID.
     * 
     * @return the odataId value.
     */
    public String odataId() {
        return this.odataId;
    }

    /**
     * Set the odataId property: OData entity ID; always set to null since summaries do not have an entity ID.
     * 
     * @param odataId the odataId value to set.
     * @return the Summary object itself.
     */
    public Summary withOdataId(String odataId) {
        this.odataId = odataId;
        return this;
    }

    /**
     * Get the odataContext property: OData context string; used by OData clients to resolve type information based on
     * metadata.
     * 
     * @return the odataContext value.
     */
    public String odataContext() {
        return this.odataContext;
    }

    /**
     * Set the odataContext property: OData context string; used by OData clients to resolve type information based on
     * metadata.
     * 
     * @param odataContext the odataContext value to set.
     * @return the Summary object itself.
     */
    public Summary withOdataContext(String odataContext) {
        this.odataContext = odataContext;
        return this;
    }

    /**
     * Get the results property: Compliance summary for all policy assignments.
     * 
     * @return the results value.
     */
    public SummaryResults results() {
        return this.results;
    }

    /**
     * Set the results property: Compliance summary for all policy assignments.
     * 
     * @param results the results value to set.
     * @return the Summary object itself.
     */
    public Summary withResults(SummaryResults results) {
        this.results = results;
        return this;
    }

    /**
     * Get the policyAssignments property: Policy assignments summary.
     * 
     * @return the policyAssignments value.
     */
    public List policyAssignments() {
        return this.policyAssignments;
    }

    /**
     * Set the policyAssignments property: Policy assignments summary.
     * 
     * @param policyAssignments the policyAssignments value to set.
     * @return the Summary object itself.
     */
    public Summary withPolicyAssignments(List policyAssignments) {
        this.policyAssignments = policyAssignments;
        return this;
    }

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

    /**
     * {@inheritDoc}
     */
    @Override
    public JsonWriter toJson(JsonWriter jsonWriter) throws IOException {
        jsonWriter.writeStartObject();
        jsonWriter.writeStringField("@odata.id", this.odataId);
        jsonWriter.writeStringField("@odata.context", this.odataContext);
        jsonWriter.writeJsonField("results", this.results);
        jsonWriter.writeArrayField("policyAssignments", this.policyAssignments,
            (writer, element) -> writer.writeJson(element));
        return jsonWriter.writeEndObject();
    }

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

                if ("@odata.id".equals(fieldName)) {
                    deserializedSummary.odataId = reader.getString();
                } else if ("@odata.context".equals(fieldName)) {
                    deserializedSummary.odataContext = reader.getString();
                } else if ("results".equals(fieldName)) {
                    deserializedSummary.results = SummaryResults.fromJson(reader);
                } else if ("policyAssignments".equals(fieldName)) {
                    List policyAssignments
                        = reader.readArray(reader1 -> PolicyAssignmentSummary.fromJson(reader1));
                    deserializedSummary.policyAssignments = policyAssignments;
                } else {
                    reader.skipChildren();
                }
            }

            return deserializedSummary;
        });
    }
}




© 2015 - 2025 Weber Informatics LLC | Privacy Policy