com.azure.resourcemanager.security.models.ActiveConnectionsNotInAllowedRange 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;
/**
* Number of active connections is not in allowed range.
*/
@Fluent
public final class ActiveConnectionsNotInAllowedRange extends TimeWindowCustomAlertRule {
/*
* The type of the custom alert rule.
*/
private String ruleType = "ActiveConnectionsNotInAllowedRange";
/**
* Creates an instance of ActiveConnectionsNotInAllowedRange class.
*/
public ActiveConnectionsNotInAllowedRange() {
}
/**
* 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 ActiveConnectionsNotInAllowedRange withTimeWindowSize(Duration timeWindowSize) {
super.withTimeWindowSize(timeWindowSize);
return this;
}
/**
* {@inheritDoc}
*/
@Override
public ActiveConnectionsNotInAllowedRange withMinThreshold(int minThreshold) {
super.withMinThreshold(minThreshold);
return this;
}
/**
* {@inheritDoc}
*/
@Override
public ActiveConnectionsNotInAllowedRange withMaxThreshold(int maxThreshold) {
super.withMaxThreshold(maxThreshold);
return this;
}
/**
* {@inheritDoc}
*/
@Override
public ActiveConnectionsNotInAllowedRange 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 ActiveConnectionsNotInAllowedRange"));
}
}
private static final ClientLogger LOGGER = new ClientLogger(ActiveConnectionsNotInAllowedRange.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 ActiveConnectionsNotInAllowedRange from the JsonReader.
*
* @param jsonReader The JsonReader being read.
* @return An instance of ActiveConnectionsNotInAllowedRange 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 ActiveConnectionsNotInAllowedRange.
*/
public static ActiveConnectionsNotInAllowedRange fromJson(JsonReader jsonReader) throws IOException {
return jsonReader.readObject(reader -> {
ActiveConnectionsNotInAllowedRange deserializedActiveConnectionsNotInAllowedRange
= new ActiveConnectionsNotInAllowedRange();
while (reader.nextToken() != JsonToken.END_OBJECT) {
String fieldName = reader.getFieldName();
reader.nextToken();
if ("isEnabled".equals(fieldName)) {
deserializedActiveConnectionsNotInAllowedRange.withIsEnabled(reader.getBoolean());
} else if ("minThreshold".equals(fieldName)) {
deserializedActiveConnectionsNotInAllowedRange.withMinThreshold(reader.getInt());
} else if ("maxThreshold".equals(fieldName)) {
deserializedActiveConnectionsNotInAllowedRange.withMaxThreshold(reader.getInt());
} else if ("timeWindowSize".equals(fieldName)) {
deserializedActiveConnectionsNotInAllowedRange.withTimeWindowSize(
reader.getNullable(nonNullReader -> Duration.parse(nonNullReader.getString())));
} else if ("displayName".equals(fieldName)) {
deserializedActiveConnectionsNotInAllowedRange.withDisplayName(reader.getString());
} else if ("description".equals(fieldName)) {
deserializedActiveConnectionsNotInAllowedRange.withDescription(reader.getString());
} else if ("ruleType".equals(fieldName)) {
deserializedActiveConnectionsNotInAllowedRange.ruleType = reader.getString();
} else {
reader.skipChildren();
}
}
return deserializedActiveConnectionsNotInAllowedRange;
});
}
}
© 2015 - 2025 Weber Informatics LLC | Privacy Policy