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

com.azure.resourcemanager.security.fluent.models.SecurityAssessmentProperties 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.fluent.models;

import com.azure.core.annotation.Fluent;
import com.azure.core.util.logging.ClientLogger;
import com.azure.json.JsonReader;
import com.azure.json.JsonToken;
import com.azure.json.JsonWriter;
import com.azure.resourcemanager.security.models.AssessmentLinks;
import com.azure.resourcemanager.security.models.AssessmentStatus;
import com.azure.resourcemanager.security.models.ResourceDetails;
import com.azure.resourcemanager.security.models.SecurityAssessmentPartnerData;
import com.azure.resourcemanager.security.models.SecurityAssessmentPropertiesBase;
import java.io.IOException;
import java.util.Map;

/**
 * Describes properties of an assessment.
 */
@Fluent
public final class SecurityAssessmentProperties extends SecurityAssessmentPropertiesBase {
    /*
     * The result of the assessment
     */
    private AssessmentStatus status;

    /*
     * Links relevant to the assessment
     */
    private AssessmentLinks links;

    /*
     * User friendly display name of the assessment
     */
    private String displayName;

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

    /**
     * Get the status property: The result of the assessment.
     * 
     * @return the status value.
     */
    public AssessmentStatus status() {
        return this.status;
    }

    /**
     * Set the status property: The result of the assessment.
     * 
     * @param status the status value to set.
     * @return the SecurityAssessmentProperties object itself.
     */
    public SecurityAssessmentProperties withStatus(AssessmentStatus status) {
        this.status = status;
        return this;
    }

    /**
     * Get the links property: Links relevant to the assessment.
     * 
     * @return the links value.
     */
    @Override
    public AssessmentLinks links() {
        return this.links;
    }

    /**
     * Get the displayName property: User friendly display name of the assessment.
     * 
     * @return the displayName value.
     */
    @Override
    public String displayName() {
        return this.displayName;
    }

    /**
     * {@inheritDoc}
     */
    @Override
    public SecurityAssessmentProperties withResourceDetails(ResourceDetails resourceDetails) {
        super.withResourceDetails(resourceDetails);
        return this;
    }

    /**
     * {@inheritDoc}
     */
    @Override
    public SecurityAssessmentProperties withAdditionalData(Map additionalData) {
        super.withAdditionalData(additionalData);
        return this;
    }

    /**
     * {@inheritDoc}
     */
    @Override
    public SecurityAssessmentProperties withMetadata(SecurityAssessmentMetadataProperties metadata) {
        super.withMetadata(metadata);
        return this;
    }

    /**
     * {@inheritDoc}
     */
    @Override
    public SecurityAssessmentProperties withPartnersData(SecurityAssessmentPartnerData partnersData) {
        super.withPartnersData(partnersData);
        return this;
    }

    /**
     * Validates the instance.
     * 
     * @throws IllegalArgumentException thrown if the instance is not valid.
     */
    @Override
    public void validate() {
        if (status() == null) {
            throw LOGGER.atError()
                .log(new IllegalArgumentException(
                    "Missing required property status in model SecurityAssessmentProperties"));
        } else {
            status().validate();
        }
        if (resourceDetails() == null) {
            throw LOGGER.atError()
                .log(new IllegalArgumentException(
                    "Missing required property resourceDetails in model SecurityAssessmentProperties"));
        } else {
            resourceDetails().validate();
        }
        if (links() != null) {
            links().validate();
        }
        if (metadata() != null) {
            metadata().validate();
        }
        if (partnersData() != null) {
            partnersData().validate();
        }
    }

    private static final ClientLogger LOGGER = new ClientLogger(SecurityAssessmentProperties.class);

    /**
     * {@inheritDoc}
     */
    @Override
    public JsonWriter toJson(JsonWriter jsonWriter) throws IOException {
        jsonWriter.writeStartObject();
        jsonWriter.writeJsonField("resourceDetails", resourceDetails());
        jsonWriter.writeMapField("additionalData", additionalData(), (writer, element) -> writer.writeString(element));
        jsonWriter.writeJsonField("metadata", metadata());
        jsonWriter.writeJsonField("partnersData", partnersData());
        jsonWriter.writeJsonField("status", this.status);
        return jsonWriter.writeEndObject();
    }

    /**
     * Reads an instance of SecurityAssessmentProperties from the JsonReader.
     * 
     * @param jsonReader The JsonReader being read.
     * @return An instance of SecurityAssessmentProperties if the JsonReader was pointing to an instance of it, or null
     * if it was pointing to JSON null.
     * @throws IllegalStateException If the deserialized JSON object was missing any required properties.
     * @throws IOException If an error occurs while reading the SecurityAssessmentProperties.
     */
    public static SecurityAssessmentProperties fromJson(JsonReader jsonReader) throws IOException {
        return jsonReader.readObject(reader -> {
            SecurityAssessmentProperties deserializedSecurityAssessmentProperties = new SecurityAssessmentProperties();
            while (reader.nextToken() != JsonToken.END_OBJECT) {
                String fieldName = reader.getFieldName();
                reader.nextToken();

                if ("resourceDetails".equals(fieldName)) {
                    deserializedSecurityAssessmentProperties.withResourceDetails(ResourceDetails.fromJson(reader));
                } else if ("displayName".equals(fieldName)) {
                    deserializedSecurityAssessmentProperties.displayName = reader.getString();
                } else if ("additionalData".equals(fieldName)) {
                    Map additionalData = reader.readMap(reader1 -> reader1.getString());
                    deserializedSecurityAssessmentProperties.withAdditionalData(additionalData);
                } else if ("links".equals(fieldName)) {
                    deserializedSecurityAssessmentProperties.links = AssessmentLinks.fromJson(reader);
                } else if ("metadata".equals(fieldName)) {
                    deserializedSecurityAssessmentProperties
                        .withMetadata(SecurityAssessmentMetadataProperties.fromJson(reader));
                } else if ("partnersData".equals(fieldName)) {
                    deserializedSecurityAssessmentProperties
                        .withPartnersData(SecurityAssessmentPartnerData.fromJson(reader));
                } else if ("status".equals(fieldName)) {
                    deserializedSecurityAssessmentProperties.status = AssessmentStatus.fromJson(reader);
                } else {
                    reader.skipChildren();
                }
            }

            return deserializedSecurityAssessmentProperties;
        });
    }
}




© 2015 - 2025 Weber Informatics LLC | Privacy Policy