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

com.azure.resourcemanager.security.fluent.models.StandardProperties Maven / Gradle / Ivy

// 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.json.JsonReader;
import com.azure.json.JsonSerializable;
import com.azure.json.JsonToken;
import com.azure.json.JsonWriter;
import com.azure.resourcemanager.security.models.PartialAssessmentProperties;
import com.azure.resourcemanager.security.models.StandardMetadata;
import com.azure.resourcemanager.security.models.StandardSupportedCloud;
import com.azure.resourcemanager.security.models.StandardType;
import java.io.IOException;
import java.util.List;

/**
 * Describes properties of a standard.
 */
@Fluent
public final class StandardProperties implements JsonSerializable {
    /*
     * Display name of the standard, equivalent to the standardId
     */
    private String displayName;

    /*
     * Standard type (Custom or Default or Compliance only currently)
     */
    private StandardType standardType;

    /*
     * Description of the standard
     */
    private String description;

    /*
     * List of assessment keys to apply to standard scope.
     */
    private List assessments;

    /*
     * List of all standard supported clouds.
     */
    private List cloudProviders;

    /*
     * The policy set definition id associated with the standard.
     */
    private String policySetDefinitionId;

    /*
     * The security standard metadata.
     */
    private StandardMetadata metadata;

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

    /**
     * Get the displayName property: Display name of the standard, equivalent to the standardId.
     * 
     * @return the displayName value.
     */
    public String displayName() {
        return this.displayName;
    }

    /**
     * Set the displayName property: Display name of the standard, equivalent to the standardId.
     * 
     * @param displayName the displayName value to set.
     * @return the StandardProperties object itself.
     */
    public StandardProperties withDisplayName(String displayName) {
        this.displayName = displayName;
        return this;
    }

    /**
     * Get the standardType property: Standard type (Custom or Default or Compliance only currently).
     * 
     * @return the standardType value.
     */
    public StandardType standardType() {
        return this.standardType;
    }

    /**
     * Get the description property: Description of the standard.
     * 
     * @return the description value.
     */
    public String description() {
        return this.description;
    }

    /**
     * Set the description property: Description of the standard.
     * 
     * @param description the description value to set.
     * @return the StandardProperties object itself.
     */
    public StandardProperties withDescription(String description) {
        this.description = description;
        return this;
    }

    /**
     * Get the assessments property: List of assessment keys to apply to standard scope.
     * 
     * @return the assessments value.
     */
    public List assessments() {
        return this.assessments;
    }

    /**
     * Set the assessments property: List of assessment keys to apply to standard scope.
     * 
     * @param assessments the assessments value to set.
     * @return the StandardProperties object itself.
     */
    public StandardProperties withAssessments(List assessments) {
        this.assessments = assessments;
        return this;
    }

    /**
     * Get the cloudProviders property: List of all standard supported clouds.
     * 
     * @return the cloudProviders value.
     */
    public List cloudProviders() {
        return this.cloudProviders;
    }

    /**
     * Set the cloudProviders property: List of all standard supported clouds.
     * 
     * @param cloudProviders the cloudProviders value to set.
     * @return the StandardProperties object itself.
     */
    public StandardProperties withCloudProviders(List cloudProviders) {
        this.cloudProviders = cloudProviders;
        return this;
    }

    /**
     * Get the policySetDefinitionId property: The policy set definition id associated with the standard.
     * 
     * @return the policySetDefinitionId value.
     */
    public String policySetDefinitionId() {
        return this.policySetDefinitionId;
    }

    /**
     * Set the policySetDefinitionId property: The policy set definition id associated with the standard.
     * 
     * @param policySetDefinitionId the policySetDefinitionId value to set.
     * @return the StandardProperties object itself.
     */
    public StandardProperties withPolicySetDefinitionId(String policySetDefinitionId) {
        this.policySetDefinitionId = policySetDefinitionId;
        return this;
    }

    /**
     * Get the metadata property: The security standard metadata.
     * 
     * @return the metadata value.
     */
    public StandardMetadata metadata() {
        return this.metadata;
    }

    /**
     * Set the metadata property: The security standard metadata.
     * 
     * @param metadata the metadata value to set.
     * @return the StandardProperties object itself.
     */
    public StandardProperties withMetadata(StandardMetadata metadata) {
        this.metadata = metadata;
        return this;
    }

    /**
     * Validates the instance.
     * 
     * @throws IllegalArgumentException thrown if the instance is not valid.
     */
    public void validate() {
        if (assessments() != null) {
            assessments().forEach(e -> e.validate());
        }
        if (metadata() != null) {
            metadata().validate();
        }
    }

    /**
     * {@inheritDoc}
     */
    @Override
    public JsonWriter toJson(JsonWriter jsonWriter) throws IOException {
        jsonWriter.writeStartObject();
        jsonWriter.writeStringField("displayName", this.displayName);
        jsonWriter.writeStringField("description", this.description);
        jsonWriter.writeArrayField("assessments", this.assessments, (writer, element) -> writer.writeJson(element));
        jsonWriter.writeArrayField("cloudProviders", this.cloudProviders,
            (writer, element) -> writer.writeString(element == null ? null : element.toString()));
        jsonWriter.writeStringField("policySetDefinitionId", this.policySetDefinitionId);
        jsonWriter.writeJsonField("metadata", this.metadata);
        return jsonWriter.writeEndObject();
    }

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

                if ("displayName".equals(fieldName)) {
                    deserializedStandardProperties.displayName = reader.getString();
                } else if ("standardType".equals(fieldName)) {
                    deserializedStandardProperties.standardType = StandardType.fromString(reader.getString());
                } else if ("description".equals(fieldName)) {
                    deserializedStandardProperties.description = reader.getString();
                } else if ("assessments".equals(fieldName)) {
                    List assessments
                        = reader.readArray(reader1 -> PartialAssessmentProperties.fromJson(reader1));
                    deserializedStandardProperties.assessments = assessments;
                } else if ("cloudProviders".equals(fieldName)) {
                    List cloudProviders
                        = reader.readArray(reader1 -> StandardSupportedCloud.fromString(reader1.getString()));
                    deserializedStandardProperties.cloudProviders = cloudProviders;
                } else if ("policySetDefinitionId".equals(fieldName)) {
                    deserializedStandardProperties.policySetDefinitionId = reader.getString();
                } else if ("metadata".equals(fieldName)) {
                    deserializedStandardProperties.metadata = StandardMetadata.fromJson(reader);
                } else {
                    reader.skipChildren();
                }
            }

            return deserializedStandardProperties;
        });
    }
}




© 2015 - 2025 Weber Informatics LLC | Privacy Policy