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

com.azure.resourcemanager.security.models.MqttD2CMessagesNotInAllowedRange 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.CoreUtils;
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.time.Duration;

/**
 * Number of device to cloud messages (MQTT protocol) is not in allowed range.
 */
@Fluent
public final class MqttD2CMessagesNotInAllowedRange extends TimeWindowCustomAlertRule {
    /*
     * The type of the custom alert rule.
     */
    private String ruleType = "MqttD2CMessagesNotInAllowedRange";

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

    /**
     * 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 MqttD2CMessagesNotInAllowedRange withTimeWindowSize(Duration timeWindowSize) {
        super.withTimeWindowSize(timeWindowSize);
        return this;
    }

    /**
     * {@inheritDoc}
     */
    @Override
    public MqttD2CMessagesNotInAllowedRange withMinThreshold(int minThreshold) {
        super.withMinThreshold(minThreshold);
        return this;
    }

    /**
     * {@inheritDoc}
     */
    @Override
    public MqttD2CMessagesNotInAllowedRange withMaxThreshold(int maxThreshold) {
        super.withMaxThreshold(maxThreshold);
        return this;
    }

    /**
     * {@inheritDoc}
     */
    @Override
    public MqttD2CMessagesNotInAllowedRange 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 (timeWindowSize() == null) {
            throw LOGGER.atError()
                .log(new IllegalArgumentException(
                    "Missing required property timeWindowSize in model MqttD2CMessagesNotInAllowedRange"));
        }
    }

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

    /**
     * {@inheritDoc}
     */
    @Override
    public JsonWriter toJson(JsonWriter jsonWriter) throws IOException {
        jsonWriter.writeStartObject();
        jsonWriter.writeBooleanField("isEnabled", isEnabled());
        jsonWriter.writeIntField("minThreshold", minThreshold());
        jsonWriter.writeIntField("maxThreshold", maxThreshold());
        jsonWriter.writeStringField("timeWindowSize", CoreUtils.durationToStringWithDays(timeWindowSize()));
        jsonWriter.writeStringField("ruleType", this.ruleType);
        return jsonWriter.writeEndObject();
    }

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

                if ("isEnabled".equals(fieldName)) {
                    deserializedMqttD2CMessagesNotInAllowedRange.withIsEnabled(reader.getBoolean());
                } else if ("minThreshold".equals(fieldName)) {
                    deserializedMqttD2CMessagesNotInAllowedRange.withMinThreshold(reader.getInt());
                } else if ("maxThreshold".equals(fieldName)) {
                    deserializedMqttD2CMessagesNotInAllowedRange.withMaxThreshold(reader.getInt());
                } else if ("timeWindowSize".equals(fieldName)) {
                    deserializedMqttD2CMessagesNotInAllowedRange.withTimeWindowSize(
                        reader.getNullable(nonNullReader -> Duration.parse(nonNullReader.getString())));
                } else if ("displayName".equals(fieldName)) {
                    deserializedMqttD2CMessagesNotInAllowedRange.withDisplayName(reader.getString());
                } else if ("description".equals(fieldName)) {
                    deserializedMqttD2CMessagesNotInAllowedRange.withDescription(reader.getString());
                } else if ("ruleType".equals(fieldName)) {
                    deserializedMqttD2CMessagesNotInAllowedRange.ruleType = reader.getString();
                } else {
                    reader.skipChildren();
                }
            }

            return deserializedMqttD2CMessagesNotInAllowedRange;
        });
    }
}




© 2015 - 2025 Weber Informatics LLC | Privacy Policy