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

com.azure.resourcemanager.securityinsights.models.GetInsightsResultsMetadata 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;

/**
 * Get Insights result metadata.
 */
@Fluent
public final class GetInsightsResultsMetadata implements JsonSerializable {
    /*
     * the total items found for the insights request
     */
    private int totalCount;

    /*
     * information about the failed queries
     */
    private List errors;

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

    /**
     * Get the totalCount property: the total items found for the insights request.
     * 
     * @return the totalCount value.
     */
    public int totalCount() {
        return this.totalCount;
    }

    /**
     * Set the totalCount property: the total items found for the insights request.
     * 
     * @param totalCount the totalCount value to set.
     * @return the GetInsightsResultsMetadata object itself.
     */
    public GetInsightsResultsMetadata withTotalCount(int totalCount) {
        this.totalCount = totalCount;
        return this;
    }

    /**
     * Get the errors property: information about the failed queries.
     * 
     * @return the errors value.
     */
    public List errors() {
        return this.errors;
    }

    /**
     * Set the errors property: information about the failed queries.
     * 
     * @param errors the errors value to set.
     * @return the GetInsightsResultsMetadata object itself.
     */
    public GetInsightsResultsMetadata withErrors(List errors) {
        this.errors = errors;
        return this;
    }

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

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

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

                if ("totalCount".equals(fieldName)) {
                    deserializedGetInsightsResultsMetadata.totalCount = reader.getInt();
                } else if ("errors".equals(fieldName)) {
                    List errors
                        = reader.readArray(reader1 -> GetInsightsErrorKind.fromJson(reader1));
                    deserializedGetInsightsResultsMetadata.errors = errors;
                } else {
                    reader.skipChildren();
                }
            }

            return deserializedGetInsightsResultsMetadata;
        });
    }
}




© 2015 - 2024 Weber Informatics LLC | Privacy Policy