com.azure.resourcemanager.security.models.TimeWindowCustomAlertRule Maven / Gradle / Ivy
Go to download
Show more of this group Show more artifacts with this name
Show all versions of azure-resourcemanager-security Show documentation
Show all versions of azure-resourcemanager-security Show documentation
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.
// 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;
/**
* A custom alert rule that checks if the number of activities (depends on the custom alert type) in a time window is
* within the given range.
*/
@Fluent
public class TimeWindowCustomAlertRule extends ThresholdCustomAlertRule {
/*
* The type of the custom alert rule.
*/
private String ruleType = "TimeWindowCustomAlertRule";
/*
* The time window size in iso8601 format.
*/
private Duration timeWindowSize;
/**
* Creates an instance of TimeWindowCustomAlertRule class.
*/
public TimeWindowCustomAlertRule() {
}
/**
* Get the ruleType property: The type of the custom alert rule.
*
* @return the ruleType value.
*/
@Override
public String ruleType() {
return this.ruleType;
}
/**
* Get the timeWindowSize property: The time window size in iso8601 format.
*
* @return the timeWindowSize value.
*/
public Duration timeWindowSize() {
return this.timeWindowSize;
}
/**
* Set the timeWindowSize property: The time window size in iso8601 format.
*
* @param timeWindowSize the timeWindowSize value to set.
* @return the TimeWindowCustomAlertRule object itself.
*/
public TimeWindowCustomAlertRule withTimeWindowSize(Duration timeWindowSize) {
this.timeWindowSize = timeWindowSize;
return this;
}
/**
* {@inheritDoc}
*/
@Override
public TimeWindowCustomAlertRule withMinThreshold(int minThreshold) {
super.withMinThreshold(minThreshold);
return this;
}
/**
* {@inheritDoc}
*/
@Override
public TimeWindowCustomAlertRule withMaxThreshold(int maxThreshold) {
super.withMaxThreshold(maxThreshold);
return this;
}
/**
* {@inheritDoc}
*/
@Override
public TimeWindowCustomAlertRule 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 TimeWindowCustomAlertRule"));
}
}
private static final ClientLogger LOGGER = new ClientLogger(TimeWindowCustomAlertRule.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(this.timeWindowSize));
jsonWriter.writeStringField("ruleType", this.ruleType);
return jsonWriter.writeEndObject();
}
/**
* Reads an instance of TimeWindowCustomAlertRule from the JsonReader.
*
* @param jsonReader The JsonReader being read.
* @return An instance of TimeWindowCustomAlertRule 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 TimeWindowCustomAlertRule.
*/
public static TimeWindowCustomAlertRule fromJson(JsonReader jsonReader) throws IOException {
return jsonReader.readObject(reader -> {
String discriminatorValue = null;
try (JsonReader readerToUse = reader.bufferObject()) {
readerToUse.nextToken(); // Prepare for reading
while (readerToUse.nextToken() != JsonToken.END_OBJECT) {
String fieldName = readerToUse.getFieldName();
readerToUse.nextToken();
if ("ruleType".equals(fieldName)) {
discriminatorValue = readerToUse.getString();
break;
} else {
readerToUse.skipChildren();
}
}
// Use the discriminator value to determine which subtype should be deserialized.
if ("ActiveConnectionsNotInAllowedRange".equals(discriminatorValue)) {
return ActiveConnectionsNotInAllowedRange.fromJson(readerToUse.reset());
} else if ("AmqpC2DMessagesNotInAllowedRange".equals(discriminatorValue)) {
return AmqpC2DMessagesNotInAllowedRange.fromJson(readerToUse.reset());
} else if ("MqttC2DMessagesNotInAllowedRange".equals(discriminatorValue)) {
return MqttC2DMessagesNotInAllowedRange.fromJson(readerToUse.reset());
} else if ("HttpC2DMessagesNotInAllowedRange".equals(discriminatorValue)) {
return HttpC2DMessagesNotInAllowedRange.fromJson(readerToUse.reset());
} else if ("AmqpC2DRejectedMessagesNotInAllowedRange".equals(discriminatorValue)) {
return AmqpC2DRejectedMessagesNotInAllowedRange.fromJson(readerToUse.reset());
} else if ("MqttC2DRejectedMessagesNotInAllowedRange".equals(discriminatorValue)) {
return MqttC2DRejectedMessagesNotInAllowedRange.fromJson(readerToUse.reset());
} else if ("HttpC2DRejectedMessagesNotInAllowedRange".equals(discriminatorValue)) {
return HttpC2DRejectedMessagesNotInAllowedRange.fromJson(readerToUse.reset());
} else if ("AmqpD2CMessagesNotInAllowedRange".equals(discriminatorValue)) {
return AmqpD2CMessagesNotInAllowedRange.fromJson(readerToUse.reset());
} else if ("MqttD2CMessagesNotInAllowedRange".equals(discriminatorValue)) {
return MqttD2CMessagesNotInAllowedRange.fromJson(readerToUse.reset());
} else if ("HttpD2CMessagesNotInAllowedRange".equals(discriminatorValue)) {
return HttpD2CMessagesNotInAllowedRange.fromJson(readerToUse.reset());
} else if ("DirectMethodInvokesNotInAllowedRange".equals(discriminatorValue)) {
return DirectMethodInvokesNotInAllowedRange.fromJson(readerToUse.reset());
} else if ("FailedLocalLoginsNotInAllowedRange".equals(discriminatorValue)) {
return FailedLocalLoginsNotInAllowedRange.fromJson(readerToUse.reset());
} else if ("FileUploadsNotInAllowedRange".equals(discriminatorValue)) {
return FileUploadsNotInAllowedRange.fromJson(readerToUse.reset());
} else if ("QueuePurgesNotInAllowedRange".equals(discriminatorValue)) {
return QueuePurgesNotInAllowedRange.fromJson(readerToUse.reset());
} else if ("TwinUpdatesNotInAllowedRange".equals(discriminatorValue)) {
return TwinUpdatesNotInAllowedRange.fromJson(readerToUse.reset());
} else if ("UnauthorizedOperationsNotInAllowedRange".equals(discriminatorValue)) {
return UnauthorizedOperationsNotInAllowedRange.fromJson(readerToUse.reset());
} else {
return fromJsonKnownDiscriminator(readerToUse.reset());
}
}
});
}
static TimeWindowCustomAlertRule fromJsonKnownDiscriminator(JsonReader jsonReader) throws IOException {
return jsonReader.readObject(reader -> {
TimeWindowCustomAlertRule deserializedTimeWindowCustomAlertRule = new TimeWindowCustomAlertRule();
while (reader.nextToken() != JsonToken.END_OBJECT) {
String fieldName = reader.getFieldName();
reader.nextToken();
if ("isEnabled".equals(fieldName)) {
deserializedTimeWindowCustomAlertRule.withIsEnabled(reader.getBoolean());
} else if ("minThreshold".equals(fieldName)) {
deserializedTimeWindowCustomAlertRule.withMinThreshold(reader.getInt());
} else if ("maxThreshold".equals(fieldName)) {
deserializedTimeWindowCustomAlertRule.withMaxThreshold(reader.getInt());
} else if ("displayName".equals(fieldName)) {
deserializedTimeWindowCustomAlertRule.withDisplayName(reader.getString());
} else if ("description".equals(fieldName)) {
deserializedTimeWindowCustomAlertRule.withDescription(reader.getString());
} else if ("timeWindowSize".equals(fieldName)) {
deserializedTimeWindowCustomAlertRule.timeWindowSize
= reader.getNullable(nonNullReader -> Duration.parse(nonNullReader.getString()));
} else if ("ruleType".equals(fieldName)) {
deserializedTimeWindowCustomAlertRule.ruleType = reader.getString();
} else {
reader.skipChildren();
}
}
return deserializedTimeWindowCustomAlertRule;
});
}
}
© 2015 - 2025 Weber Informatics LLC | Privacy Policy