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

com.azure.resourcemanager.security.models.ServerVulnerabilityProperties 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.Immutable;
import com.azure.core.util.CoreUtils;
import com.azure.json.JsonReader;
import com.azure.json.JsonToken;
import com.azure.json.JsonWriter;
import java.io.IOException;
import java.time.OffsetDateTime;
import java.util.List;
import java.util.Map;

/**
 * Additional context fields for server vulnerability assessment.
 */
@Immutable
public final class ServerVulnerabilityProperties extends AdditionalData {
    /*
     * Sub-assessment resource type
     */
    private AssessedResourceType assessedResourceType
        = AssessedResourceType.fromString("ServerVulnerabilityAssessment");

    /*
     * Vulnerability Type. e.g: Vulnerability, Potential Vulnerability, Information Gathered
     */
    private String type;

    /*
     * Dictionary from cvss version to cvss details object
     */
    private Map cvss;

    /*
     * Indicates whether a patch is available or not
     */
    private Boolean patchable;

    /*
     * List of CVEs
     */
    private List cve;

    /*
     * Threat name
     */
    private String threat;

    /*
     * Published time
     */
    private OffsetDateTime publishedTime;

    /*
     * The vendorReferences property.
     */
    private List vendorReferences;

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

    /**
     * Get the assessedResourceType property: Sub-assessment resource type.
     * 
     * @return the assessedResourceType value.
     */
    @Override
    public AssessedResourceType assessedResourceType() {
        return this.assessedResourceType;
    }

    /**
     * Get the type property: Vulnerability Type. e.g: Vulnerability, Potential Vulnerability, Information Gathered.
     * 
     * @return the type value.
     */
    public String type() {
        return this.type;
    }

    /**
     * Get the cvss property: Dictionary from cvss version to cvss details object.
     * 
     * @return the cvss value.
     */
    public Map cvss() {
        return this.cvss;
    }

    /**
     * Get the patchable property: Indicates whether a patch is available or not.
     * 
     * @return the patchable value.
     */
    public Boolean patchable() {
        return this.patchable;
    }

    /**
     * Get the cve property: List of CVEs.
     * 
     * @return the cve value.
     */
    public List cve() {
        return this.cve;
    }

    /**
     * Get the threat property: Threat name.
     * 
     * @return the threat value.
     */
    public String threat() {
        return this.threat;
    }

    /**
     * Get the publishedTime property: Published time.
     * 
     * @return the publishedTime value.
     */
    public OffsetDateTime publishedTime() {
        return this.publishedTime;
    }

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

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

    /**
     * {@inheritDoc}
     */
    @Override
    public JsonWriter toJson(JsonWriter jsonWriter) throws IOException {
        jsonWriter.writeStartObject();
        jsonWriter.writeStringField("assessedResourceType",
            this.assessedResourceType == null ? null : this.assessedResourceType.toString());
        return jsonWriter.writeEndObject();
    }

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

                if ("assessedResourceType".equals(fieldName)) {
                    deserializedServerVulnerabilityProperties.assessedResourceType
                        = AssessedResourceType.fromString(reader.getString());
                } else if ("type".equals(fieldName)) {
                    deserializedServerVulnerabilityProperties.type = reader.getString();
                } else if ("cvss".equals(fieldName)) {
                    Map cvss = reader.readMap(reader1 -> Cvss.fromJson(reader1));
                    deserializedServerVulnerabilityProperties.cvss = cvss;
                } else if ("patchable".equals(fieldName)) {
                    deserializedServerVulnerabilityProperties.patchable = reader.getNullable(JsonReader::getBoolean);
                } else if ("cve".equals(fieldName)) {
                    List cve = reader.readArray(reader1 -> Cve.fromJson(reader1));
                    deserializedServerVulnerabilityProperties.cve = cve;
                } else if ("threat".equals(fieldName)) {
                    deserializedServerVulnerabilityProperties.threat = reader.getString();
                } else if ("publishedTime".equals(fieldName)) {
                    deserializedServerVulnerabilityProperties.publishedTime = reader
                        .getNullable(nonNullReader -> CoreUtils.parseBestOffsetDateTime(nonNullReader.getString()));
                } else if ("vendorReferences".equals(fieldName)) {
                    List vendorReferences
                        = reader.readArray(reader1 -> VendorReference.fromJson(reader1));
                    deserializedServerVulnerabilityProperties.vendorReferences = vendorReferences;
                } else {
                    reader.skipChildren();
                }
            }

            return deserializedServerVulnerabilityProperties;
        });
    }
}




© 2015 - 2025 Weber Informatics LLC | Privacy Policy