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

com.azure.resourcemanager.security.models.AssessmentStatus 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.Fluent;
import com.azure.core.util.logging.ClientLogger;
import com.azure.json.JsonReader;
import com.azure.json.JsonSerializable;
import com.azure.json.JsonToken;
import com.azure.json.JsonWriter;
import java.io.IOException;

/**
 * The result of the assessment.
 */
@Fluent
public class AssessmentStatus implements JsonSerializable {
    /*
     * Programmatic code for the status of the assessment
     */
    private AssessmentStatusCode code;

    /*
     * Programmatic code for the cause of the assessment status
     */
    private String cause;

    /*
     * Human readable description of the assessment status
     */
    private String description;

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

    /**
     * Get the code property: Programmatic code for the status of the assessment.
     * 
     * @return the code value.
     */
    public AssessmentStatusCode code() {
        return this.code;
    }

    /**
     * Set the code property: Programmatic code for the status of the assessment.
     * 
     * @param code the code value to set.
     * @return the AssessmentStatus object itself.
     */
    public AssessmentStatus withCode(AssessmentStatusCode code) {
        this.code = code;
        return this;
    }

    /**
     * Get the cause property: Programmatic code for the cause of the assessment status.
     * 
     * @return the cause value.
     */
    public String cause() {
        return this.cause;
    }

    /**
     * Set the cause property: Programmatic code for the cause of the assessment status.
     * 
     * @param cause the cause value to set.
     * @return the AssessmentStatus object itself.
     */
    public AssessmentStatus withCause(String cause) {
        this.cause = cause;
        return this;
    }

    /**
     * Get the description property: Human readable description of the assessment status.
     * 
     * @return the description value.
     */
    public String description() {
        return this.description;
    }

    /**
     * Set the description property: Human readable description of the assessment status.
     * 
     * @param description the description value to set.
     * @return the AssessmentStatus object itself.
     */
    public AssessmentStatus withDescription(String description) {
        this.description = description;
        return this;
    }

    /**
     * Validates the instance.
     * 
     * @throws IllegalArgumentException thrown if the instance is not valid.
     */
    public void validate() {
        if (code() == null) {
            throw LOGGER.atError()
                .log(new IllegalArgumentException("Missing required property code in model AssessmentStatus"));
        }
    }

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

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

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

                if ("code".equals(fieldName)) {
                    deserializedAssessmentStatus.code = AssessmentStatusCode.fromString(reader.getString());
                } else if ("cause".equals(fieldName)) {
                    deserializedAssessmentStatus.cause = reader.getString();
                } else if ("description".equals(fieldName)) {
                    deserializedAssessmentStatus.description = reader.getString();
                } else {
                    reader.skipChildren();
                }
            }

            return deserializedAssessmentStatus;
        });
    }
}




© 2015 - 2025 Weber Informatics LLC | Privacy Policy