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

com.azure.resourcemanager.security.models.VaRule Maven / Gradle / Ivy

Go to download

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

There is a newer version: 1.0.0
Show 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.security.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;

/**
 * vulnerability assessment rule metadata details.
 */
@Fluent
public final class VaRule implements JsonSerializable {
    /*
     * The rule Id.
     */
    private String ruleId;

    /*
     * The rule severity.
     */
    private RuleSeverity severity;

    /*
     * The rule category.
     */
    private String category;

    /*
     * The rule type.
     */
    private RuleType ruleType;

    /*
     * The rule title.
     */
    private String title;

    /*
     * The rule description.
     */
    private String description;

    /*
     * The rule rationale.
     */
    private String rationale;

    /*
     * The rule query details.
     */
    private QueryCheck queryCheck;

    /*
     * The benchmark references.
     */
    private List benchmarkReferences;

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

    /**
     * Get the ruleId property: The rule Id.
     * 
     * @return the ruleId value.
     */
    public String ruleId() {
        return this.ruleId;
    }

    /**
     * Set the ruleId property: The rule Id.
     * 
     * @param ruleId the ruleId value to set.
     * @return the VaRule object itself.
     */
    public VaRule withRuleId(String ruleId) {
        this.ruleId = ruleId;
        return this;
    }

    /**
     * Get the severity property: The rule severity.
     * 
     * @return the severity value.
     */
    public RuleSeverity severity() {
        return this.severity;
    }

    /**
     * Set the severity property: The rule severity.
     * 
     * @param severity the severity value to set.
     * @return the VaRule object itself.
     */
    public VaRule withSeverity(RuleSeverity severity) {
        this.severity = severity;
        return this;
    }

    /**
     * Get the category property: The rule category.
     * 
     * @return the category value.
     */
    public String category() {
        return this.category;
    }

    /**
     * Set the category property: The rule category.
     * 
     * @param category the category value to set.
     * @return the VaRule object itself.
     */
    public VaRule withCategory(String category) {
        this.category = category;
        return this;
    }

    /**
     * Get the ruleType property: The rule type.
     * 
     * @return the ruleType value.
     */
    public RuleType ruleType() {
        return this.ruleType;
    }

    /**
     * Set the ruleType property: The rule type.
     * 
     * @param ruleType the ruleType value to set.
     * @return the VaRule object itself.
     */
    public VaRule withRuleType(RuleType ruleType) {
        this.ruleType = ruleType;
        return this;
    }

    /**
     * Get the title property: The rule title.
     * 
     * @return the title value.
     */
    public String title() {
        return this.title;
    }

    /**
     * Set the title property: The rule title.
     * 
     * @param title the title value to set.
     * @return the VaRule object itself.
     */
    public VaRule withTitle(String title) {
        this.title = title;
        return this;
    }

    /**
     * Get the description property: The rule description.
     * 
     * @return the description value.
     */
    public String description() {
        return this.description;
    }

    /**
     * Set the description property: The rule description.
     * 
     * @param description the description value to set.
     * @return the VaRule object itself.
     */
    public VaRule withDescription(String description) {
        this.description = description;
        return this;
    }

    /**
     * Get the rationale property: The rule rationale.
     * 
     * @return the rationale value.
     */
    public String rationale() {
        return this.rationale;
    }

    /**
     * Set the rationale property: The rule rationale.
     * 
     * @param rationale the rationale value to set.
     * @return the VaRule object itself.
     */
    public VaRule withRationale(String rationale) {
        this.rationale = rationale;
        return this;
    }

    /**
     * Get the queryCheck property: The rule query details.
     * 
     * @return the queryCheck value.
     */
    public QueryCheck queryCheck() {
        return this.queryCheck;
    }

    /**
     * Set the queryCheck property: The rule query details.
     * 
     * @param queryCheck the queryCheck value to set.
     * @return the VaRule object itself.
     */
    public VaRule withQueryCheck(QueryCheck queryCheck) {
        this.queryCheck = queryCheck;
        return this;
    }

    /**
     * Get the benchmarkReferences property: The benchmark references.
     * 
     * @return the benchmarkReferences value.
     */
    public List benchmarkReferences() {
        return this.benchmarkReferences;
    }

    /**
     * Set the benchmarkReferences property: The benchmark references.
     * 
     * @param benchmarkReferences the benchmarkReferences value to set.
     * @return the VaRule object itself.
     */
    public VaRule withBenchmarkReferences(List benchmarkReferences) {
        this.benchmarkReferences = benchmarkReferences;
        return this;
    }

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

    /**
     * {@inheritDoc}
     */
    @Override
    public JsonWriter toJson(JsonWriter jsonWriter) throws IOException {
        jsonWriter.writeStartObject();
        jsonWriter.writeStringField("ruleId", this.ruleId);
        jsonWriter.writeStringField("severity", this.severity == null ? null : this.severity.toString());
        jsonWriter.writeStringField("category", this.category);
        jsonWriter.writeStringField("ruleType", this.ruleType == null ? null : this.ruleType.toString());
        jsonWriter.writeStringField("title", this.title);
        jsonWriter.writeStringField("description", this.description);
        jsonWriter.writeStringField("rationale", this.rationale);
        jsonWriter.writeJsonField("queryCheck", this.queryCheck);
        jsonWriter.writeArrayField("benchmarkReferences", this.benchmarkReferences,
            (writer, element) -> writer.writeJson(element));
        return jsonWriter.writeEndObject();
    }

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

                if ("ruleId".equals(fieldName)) {
                    deserializedVaRule.ruleId = reader.getString();
                } else if ("severity".equals(fieldName)) {
                    deserializedVaRule.severity = RuleSeverity.fromString(reader.getString());
                } else if ("category".equals(fieldName)) {
                    deserializedVaRule.category = reader.getString();
                } else if ("ruleType".equals(fieldName)) {
                    deserializedVaRule.ruleType = RuleType.fromString(reader.getString());
                } else if ("title".equals(fieldName)) {
                    deserializedVaRule.title = reader.getString();
                } else if ("description".equals(fieldName)) {
                    deserializedVaRule.description = reader.getString();
                } else if ("rationale".equals(fieldName)) {
                    deserializedVaRule.rationale = reader.getString();
                } else if ("queryCheck".equals(fieldName)) {
                    deserializedVaRule.queryCheck = QueryCheck.fromJson(reader);
                } else if ("benchmarkReferences".equals(fieldName)) {
                    List benchmarkReferences
                        = reader.readArray(reader1 -> BenchmarkReference.fromJson(reader1));
                    deserializedVaRule.benchmarkReferences = benchmarkReferences;
                } else {
                    reader.skipChildren();
                }
            }

            return deserializedVaRule;
        });
    }
}




© 2015 - 2025 Weber Informatics LLC | Privacy Policy