com.azure.resourcemanager.securityinsights.models.GroupingConfiguration Maven / Gradle / Ivy
Go to download
Show more of this group Show more artifacts with this name
Show all versions of azure-resourcemanager-securityinsights Show documentation
Show all versions of azure-resourcemanager-securityinsights Show documentation
This package contains Microsoft Azure SDK for SecurityInsights Management SDK. For documentation on how to use this package, please see https://aka.ms/azsdk/java/mgmt. API spec for Microsoft.SecurityInsights (Azure Security Insights) resource provider. Package tag package-preview-2022-09.
The 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.securityinsights.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.JsonSerializable;
import com.azure.json.JsonToken;
import com.azure.json.JsonWriter;
import java.io.IOException;
import java.time.Duration;
import java.util.List;
/**
* Grouping configuration property bag.
*/
@Fluent
public final class GroupingConfiguration implements JsonSerializable {
/*
* Grouping enabled
*/
private boolean enabled;
/*
* Re-open closed matching incidents
*/
private boolean reopenClosedIncident;
/*
* Limit the group to alerts created within the lookback duration (in ISO 8601 duration format)
*/
private Duration lookbackDuration;
/*
* Grouping matching method. When method is Selected at least one of groupByEntities, groupByAlertDetails,
* groupByCustomDetails must be provided and not empty.
*/
private MatchingMethod matchingMethod;
/*
* A list of entity types to group by (when matchingMethod is Selected). Only entities defined in the current alert
* rule may be used.
*/
private List groupByEntities;
/*
* A list of alert details to group by (when matchingMethod is Selected)
*/
private List groupByAlertDetails;
/*
* A list of custom details keys to group by (when matchingMethod is Selected). Only keys defined in the current
* alert rule may be used.
*/
private List groupByCustomDetails;
/**
* Creates an instance of GroupingConfiguration class.
*/
public GroupingConfiguration() {
}
/**
* Get the enabled property: Grouping enabled.
*
* @return the enabled value.
*/
public boolean enabled() {
return this.enabled;
}
/**
* Set the enabled property: Grouping enabled.
*
* @param enabled the enabled value to set.
* @return the GroupingConfiguration object itself.
*/
public GroupingConfiguration withEnabled(boolean enabled) {
this.enabled = enabled;
return this;
}
/**
* Get the reopenClosedIncident property: Re-open closed matching incidents.
*
* @return the reopenClosedIncident value.
*/
public boolean reopenClosedIncident() {
return this.reopenClosedIncident;
}
/**
* Set the reopenClosedIncident property: Re-open closed matching incidents.
*
* @param reopenClosedIncident the reopenClosedIncident value to set.
* @return the GroupingConfiguration object itself.
*/
public GroupingConfiguration withReopenClosedIncident(boolean reopenClosedIncident) {
this.reopenClosedIncident = reopenClosedIncident;
return this;
}
/**
* Get the lookbackDuration property: Limit the group to alerts created within the lookback duration (in ISO 8601
* duration format).
*
* @return the lookbackDuration value.
*/
public Duration lookbackDuration() {
return this.lookbackDuration;
}
/**
* Set the lookbackDuration property: Limit the group to alerts created within the lookback duration (in ISO 8601
* duration format).
*
* @param lookbackDuration the lookbackDuration value to set.
* @return the GroupingConfiguration object itself.
*/
public GroupingConfiguration withLookbackDuration(Duration lookbackDuration) {
this.lookbackDuration = lookbackDuration;
return this;
}
/**
* Get the matchingMethod property: Grouping matching method. When method is Selected at least one of
* groupByEntities, groupByAlertDetails, groupByCustomDetails must be provided and not empty.
*
* @return the matchingMethod value.
*/
public MatchingMethod matchingMethod() {
return this.matchingMethod;
}
/**
* Set the matchingMethod property: Grouping matching method. When method is Selected at least one of
* groupByEntities, groupByAlertDetails, groupByCustomDetails must be provided and not empty.
*
* @param matchingMethod the matchingMethod value to set.
* @return the GroupingConfiguration object itself.
*/
public GroupingConfiguration withMatchingMethod(MatchingMethod matchingMethod) {
this.matchingMethod = matchingMethod;
return this;
}
/**
* Get the groupByEntities property: A list of entity types to group by (when matchingMethod is Selected). Only
* entities defined in the current alert rule may be used.
*
* @return the groupByEntities value.
*/
public List groupByEntities() {
return this.groupByEntities;
}
/**
* Set the groupByEntities property: A list of entity types to group by (when matchingMethod is Selected). Only
* entities defined in the current alert rule may be used.
*
* @param groupByEntities the groupByEntities value to set.
* @return the GroupingConfiguration object itself.
*/
public GroupingConfiguration withGroupByEntities(List groupByEntities) {
this.groupByEntities = groupByEntities;
return this;
}
/**
* Get the groupByAlertDetails property: A list of alert details to group by (when matchingMethod is Selected).
*
* @return the groupByAlertDetails value.
*/
public List groupByAlertDetails() {
return this.groupByAlertDetails;
}
/**
* Set the groupByAlertDetails property: A list of alert details to group by (when matchingMethod is Selected).
*
* @param groupByAlertDetails the groupByAlertDetails value to set.
* @return the GroupingConfiguration object itself.
*/
public GroupingConfiguration withGroupByAlertDetails(List groupByAlertDetails) {
this.groupByAlertDetails = groupByAlertDetails;
return this;
}
/**
* Get the groupByCustomDetails property: A list of custom details keys to group by (when matchingMethod is
* Selected). Only keys defined in the current alert rule may be used.
*
* @return the groupByCustomDetails value.
*/
public List groupByCustomDetails() {
return this.groupByCustomDetails;
}
/**
* Set the groupByCustomDetails property: A list of custom details keys to group by (when matchingMethod is
* Selected). Only keys defined in the current alert rule may be used.
*
* @param groupByCustomDetails the groupByCustomDetails value to set.
* @return the GroupingConfiguration object itself.
*/
public GroupingConfiguration withGroupByCustomDetails(List groupByCustomDetails) {
this.groupByCustomDetails = groupByCustomDetails;
return this;
}
/**
* Validates the instance.
*
* @throws IllegalArgumentException thrown if the instance is not valid.
*/
public void validate() {
if (lookbackDuration() == null) {
throw LOGGER.atError()
.log(new IllegalArgumentException(
"Missing required property lookbackDuration in model GroupingConfiguration"));
}
if (matchingMethod() == null) {
throw LOGGER.atError()
.log(new IllegalArgumentException(
"Missing required property matchingMethod in model GroupingConfiguration"));
}
}
private static final ClientLogger LOGGER = new ClientLogger(GroupingConfiguration.class);
/**
* {@inheritDoc}
*/
@Override
public JsonWriter toJson(JsonWriter jsonWriter) throws IOException {
jsonWriter.writeStartObject();
jsonWriter.writeBooleanField("enabled", this.enabled);
jsonWriter.writeBooleanField("reopenClosedIncident", this.reopenClosedIncident);
jsonWriter.writeStringField("lookbackDuration", CoreUtils.durationToStringWithDays(this.lookbackDuration));
jsonWriter.writeStringField("matchingMethod",
this.matchingMethod == null ? null : this.matchingMethod.toString());
jsonWriter.writeArrayField("groupByEntities", this.groupByEntities,
(writer, element) -> writer.writeString(element == null ? null : element.toString()));
jsonWriter.writeArrayField("groupByAlertDetails", this.groupByAlertDetails,
(writer, element) -> writer.writeString(element == null ? null : element.toString()));
jsonWriter.writeArrayField("groupByCustomDetails", this.groupByCustomDetails,
(writer, element) -> writer.writeString(element));
return jsonWriter.writeEndObject();
}
/**
* Reads an instance of GroupingConfiguration from the JsonReader.
*
* @param jsonReader The JsonReader being read.
* @return An instance of GroupingConfiguration 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 GroupingConfiguration.
*/
public static GroupingConfiguration fromJson(JsonReader jsonReader) throws IOException {
return jsonReader.readObject(reader -> {
GroupingConfiguration deserializedGroupingConfiguration = new GroupingConfiguration();
while (reader.nextToken() != JsonToken.END_OBJECT) {
String fieldName = reader.getFieldName();
reader.nextToken();
if ("enabled".equals(fieldName)) {
deserializedGroupingConfiguration.enabled = reader.getBoolean();
} else if ("reopenClosedIncident".equals(fieldName)) {
deserializedGroupingConfiguration.reopenClosedIncident = reader.getBoolean();
} else if ("lookbackDuration".equals(fieldName)) {
deserializedGroupingConfiguration.lookbackDuration
= reader.getNullable(nonNullReader -> Duration.parse(nonNullReader.getString()));
} else if ("matchingMethod".equals(fieldName)) {
deserializedGroupingConfiguration.matchingMethod = MatchingMethod.fromString(reader.getString());
} else if ("groupByEntities".equals(fieldName)) {
List groupByEntities
= reader.readArray(reader1 -> EntityMappingType.fromString(reader1.getString()));
deserializedGroupingConfiguration.groupByEntities = groupByEntities;
} else if ("groupByAlertDetails".equals(fieldName)) {
List groupByAlertDetails
= reader.readArray(reader1 -> AlertDetail.fromString(reader1.getString()));
deserializedGroupingConfiguration.groupByAlertDetails = groupByAlertDetails;
} else if ("groupByCustomDetails".equals(fieldName)) {
List groupByCustomDetails = reader.readArray(reader1 -> reader1.getString());
deserializedGroupingConfiguration.groupByCustomDetails = groupByCustomDetails;
} else {
reader.skipChildren();
}
}
return deserializedGroupingConfiguration;
});
}
}