// 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 container registry Vulnerability assessment. */
@JsonTypeInfo(use = JsonTypeInfo.Id.NAME, include = JsonTypeInfo.As.PROPERTY, property = "assessedResourceType")
@JsonTypeName("ContainerRegistryVulnerability")
@Immutable
public final class ContainerRegistryVulnerabilityProperties extends AdditionalData {
    /*
     * Vulnerability Type. e.g: Vulnerability, Potential Vulnerability, Information Gathered, Vulnerability
     */
    @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;

    /*
     * 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;

    /*
     * Name of the repository which the vulnerable image belongs to
     */
    @JsonProperty(value = "repositoryName", access = JsonProperty.Access.WRITE_ONLY)
    private String repositoryName;

    /*
     * Digest of the vulnerable image
     */
    @JsonProperty(value = "imageDigest", access = JsonProperty.Access.WRITE_ONLY)
    private String imageDigest;

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

    /**
     * Get the type property: Vulnerability Type. e.g: Vulnerability, Potential Vulnerability, Information Gathered,
     * Vulnerability.
     *
     * @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 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;
    }

    /**
     * Get the repositoryName property: Name of the repository which the vulnerable image belongs to.
     *
     * @return the repositoryName value.
     */
    public String repositoryName() {
        return this.repositoryName;
    }

    /**
     * Get the imageDigest property: Digest of the vulnerable image.
     *
     * @return the imageDigest value.
     */
    public String imageDigest() {
        return this.imageDigest;
    }

    /**
     * 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());
        }
    }
}
