// 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.fasterxml.jackson.annotation.JsonInclude;
import com.fasterxml.jackson.annotation.JsonProperty;
import com.fasterxml.jackson.annotation.JsonTypeInfo;
import com.fasterxml.jackson.annotation.JsonTypeName;
import java.time.OffsetDateTime;
import java.util.List;
import java.util.Map;

/** Additional context fields for server vulnerability assessment. */
@JsonTypeInfo(use = JsonTypeInfo.Id.NAME, include = JsonTypeInfo.As.PROPERTY, property = "assessedResourceType")
@JsonTypeName("ServerVulnerabilityAssessment")
@Immutable
public final class ServerVulnerabilityProperties extends AdditionalData {
    /*
     * Vulnerability Type. e.g: Vulnerability, Potential Vulnerability, Information Gathered
     */
    @JsonProperty(value = "type", access = JsonProperty.Access.WRITE_ONLY)
    private String type;

    /*
     * Dictionary from cvss version to cvss details object
     */
    @JsonProperty(value = "cvss", access = JsonProperty.Access.WRITE_ONLY)
    @JsonInclude(value = JsonInclude.Include.NON_NULL, content = JsonInclude.Include.ALWAYS)
    private Map<String, Cvss> cvss;

    /*
     * Indicates whether a patch is available or not
     */
    @JsonProperty(value = "patchable", access = JsonProperty.Access.WRITE_ONLY)
    private Boolean patchable;

    /*
     * List of CVEs
     */
    @JsonProperty(value = "cve", access = JsonProperty.Access.WRITE_ONLY)
    private List<Cve> cve;

    /*
     * Threat name
     */
    @JsonProperty(value = "threat", access = JsonProperty.Access.WRITE_ONLY)
    private String threat;

    /*
     * Published time
     */
    @JsonProperty(value = "publishedTime", access = JsonProperty.Access.WRITE_ONLY)
    private OffsetDateTime publishedTime;

    /*
     * The vendorReferences property.
     */
    @JsonProperty(value = "vendorReferences", access = JsonProperty.Access.WRITE_ONLY)
    private List<VendorReference> vendorReferences;

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

    /**
     * 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<String, Cvss> 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> 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<VendorReference> vendorReferences() {
        return this.vendorReferences;
    }

    /**
     * Validates the instance.
     *
     * @throws IllegalArgumentException thrown if the instance is not valid.
     */
    @Override
    public void validate() {
        super.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());
        }
    }
}
