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

com.azure.resourcemanager.security.models.ContainerRegistryVulnerabilityProperties 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.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 container registry Vulnerability assessment.
 */
@Immutable
public final class ContainerRegistryVulnerabilityProperties extends AdditionalData {
    /*
     * Sub-assessment resource type
     */
    private AssessedResourceType assessedResourceType = AssessedResourceType.CONTAINER_REGISTRY_VULNERABILITY;

    /*
     * Vulnerability Type. e.g: Vulnerability, Potential Vulnerability, Information Gathered, Vulnerability
     */
    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;

    /*
     * Published time
     */
    private OffsetDateTime publishedTime;

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

    /*
     * Name of the repository which the vulnerable image belongs to
     */
    private String repositoryName;

    /*
     * Digest of the vulnerable image
     */
    private String imageDigest;

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

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

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

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

            return deserializedContainerRegistryVulnerabilityProperties;
        });
    }
}




© 2015 - 2025 Weber Informatics LLC | Privacy Policy