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

com.azure.resourcemanager.security.models.ProcessNotAllowed 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.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 java.io.IOException;
import java.util.List;

/**
 * Execution of a process that isn't allowed. Allow list consists of process names to allow.
 */
@Fluent
public final class ProcessNotAllowed extends AllowlistCustomAlertRule {
    /*
     * The type of the custom alert rule.
     */
    private String ruleType = "ProcessNotAllowed";

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

    /**
     * Get the ruleType property: The type of the custom alert rule.
     * 
     * @return the ruleType value.
     */
    @Override
    public String ruleType() {
        return this.ruleType;
    }

    /**
     * {@inheritDoc}
     */
    @Override
    public ProcessNotAllowed withAllowlistValues(List allowlistValues) {
        super.withAllowlistValues(allowlistValues);
        return this;
    }

    /**
     * {@inheritDoc}
     */
    @Override
    public ProcessNotAllowed withIsEnabled(boolean isEnabled) {
        super.withIsEnabled(isEnabled);
        return this;
    }

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

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

    /**
     * {@inheritDoc}
     */
    @Override
    public JsonWriter toJson(JsonWriter jsonWriter) throws IOException {
        jsonWriter.writeStartObject();
        jsonWriter.writeBooleanField("isEnabled", isEnabled());
        jsonWriter.writeArrayField("allowlistValues", allowlistValues(),
            (writer, element) -> writer.writeString(element));
        jsonWriter.writeStringField("ruleType", this.ruleType);
        return jsonWriter.writeEndObject();
    }

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

                if ("isEnabled".equals(fieldName)) {
                    deserializedProcessNotAllowed.withIsEnabled(reader.getBoolean());
                } else if ("allowlistValues".equals(fieldName)) {
                    List allowlistValues = reader.readArray(reader1 -> reader1.getString());
                    deserializedProcessNotAllowed.withAllowlistValues(allowlistValues);
                } else if ("displayName".equals(fieldName)) {
                    deserializedProcessNotAllowed.withDisplayName(reader.getString());
                } else if ("description".equals(fieldName)) {
                    deserializedProcessNotAllowed.withDescription(reader.getString());
                } else if ("valueType".equals(fieldName)) {
                    deserializedProcessNotAllowed.withValueType(ValueType.fromString(reader.getString()));
                } else if ("ruleType".equals(fieldName)) {
                    deserializedProcessNotAllowed.ruleType = reader.getString();
                } else {
                    reader.skipChildren();
                }
            }

            return deserializedProcessNotAllowed;
        });
    }
}




© 2015 - 2025 Weber Informatics LLC | Privacy Policy