com.azure.resourcemanager.securityinsights.fluent.models.FusionAlertRuleProperties 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.fluent.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 com.azure.resourcemanager.securityinsights.models.AlertSeverity;
import com.azure.resourcemanager.securityinsights.models.AttackTactic;
import com.azure.resourcemanager.securityinsights.models.FusionScenarioExclusionPattern;
import com.azure.resourcemanager.securityinsights.models.FusionSourceSettings;
import java.io.IOException;
import java.time.OffsetDateTime;
import java.util.List;
/**
* Fusion alert rule base property bag.
*/
@Fluent
public final class FusionAlertRuleProperties implements JsonSerializable {
/*
* The Name of the alert rule template used to create this rule.
*/
private String alertRuleTemplateName;
/*
* The description of the alert rule.
*/
private String description;
/*
* The display name for alerts created by this alert rule.
*/
private String displayName;
/*
* Determines whether this alert rule is enabled or disabled.
*/
private boolean enabled;
/*
* Configuration for all supported source signals in fusion detection.
*/
private List sourceSettings;
/*
* Configuration to exclude scenarios in fusion detection.
*/
private List scenarioExclusionPatterns;
/*
* The last time that this alert has been modified.
*/
private OffsetDateTime lastModifiedUtc;
/*
* The severity for alerts created by this alert rule.
*/
private AlertSeverity severity;
/*
* The tactics of the alert rule
*/
private List tactics;
/*
* The techniques of the alert rule
*/
private List techniques;
/**
* Creates an instance of FusionAlertRuleProperties class.
*/
public FusionAlertRuleProperties() {
}
/**
* Get the alertRuleTemplateName property: The Name of the alert rule template used to create this rule.
*
* @return the alertRuleTemplateName value.
*/
public String alertRuleTemplateName() {
return this.alertRuleTemplateName;
}
/**
* Set the alertRuleTemplateName property: The Name of the alert rule template used to create this rule.
*
* @param alertRuleTemplateName the alertRuleTemplateName value to set.
* @return the FusionAlertRuleProperties object itself.
*/
public FusionAlertRuleProperties withAlertRuleTemplateName(String alertRuleTemplateName) {
this.alertRuleTemplateName = alertRuleTemplateName;
return this;
}
/**
* Get the description property: The description of the alert rule.
*
* @return the description value.
*/
public String description() {
return this.description;
}
/**
* Get the displayName property: The display name for alerts created by this alert rule.
*
* @return the displayName value.
*/
public String displayName() {
return this.displayName;
}
/**
* Get the enabled property: Determines whether this alert rule is enabled or disabled.
*
* @return the enabled value.
*/
public boolean enabled() {
return this.enabled;
}
/**
* Set the enabled property: Determines whether this alert rule is enabled or disabled.
*
* @param enabled the enabled value to set.
* @return the FusionAlertRuleProperties object itself.
*/
public FusionAlertRuleProperties withEnabled(boolean enabled) {
this.enabled = enabled;
return this;
}
/**
* Get the sourceSettings property: Configuration for all supported source signals in fusion detection.
*
* @return the sourceSettings value.
*/
public List sourceSettings() {
return this.sourceSettings;
}
/**
* Set the sourceSettings property: Configuration for all supported source signals in fusion detection.
*
* @param sourceSettings the sourceSettings value to set.
* @return the FusionAlertRuleProperties object itself.
*/
public FusionAlertRuleProperties withSourceSettings(List sourceSettings) {
this.sourceSettings = sourceSettings;
return this;
}
/**
* Get the scenarioExclusionPatterns property: Configuration to exclude scenarios in fusion detection.
*
* @return the scenarioExclusionPatterns value.
*/
public List scenarioExclusionPatterns() {
return this.scenarioExclusionPatterns;
}
/**
* Set the scenarioExclusionPatterns property: Configuration to exclude scenarios in fusion detection.
*
* @param scenarioExclusionPatterns the scenarioExclusionPatterns value to set.
* @return the FusionAlertRuleProperties object itself.
*/
public FusionAlertRuleProperties
withScenarioExclusionPatterns(List scenarioExclusionPatterns) {
this.scenarioExclusionPatterns = scenarioExclusionPatterns;
return this;
}
/**
* Get the lastModifiedUtc property: The last time that this alert has been modified.
*
* @return the lastModifiedUtc value.
*/
public OffsetDateTime lastModifiedUtc() {
return this.lastModifiedUtc;
}
/**
* Get the severity property: The severity for alerts created by this alert rule.
*
* @return the severity value.
*/
public AlertSeverity severity() {
return this.severity;
}
/**
* Get the tactics property: The tactics of the alert rule.
*
* @return the tactics value.
*/
public List tactics() {
return this.tactics;
}
/**
* Get the techniques property: The techniques of the alert rule.
*
* @return the techniques value.
*/
public List techniques() {
return this.techniques;
}
/**
* Validates the instance.
*
* @throws IllegalArgumentException thrown if the instance is not valid.
*/
public void validate() {
if (alertRuleTemplateName() == null) {
throw LOGGER.atError()
.log(new IllegalArgumentException(
"Missing required property alertRuleTemplateName in model FusionAlertRuleProperties"));
}
if (sourceSettings() != null) {
sourceSettings().forEach(e -> e.validate());
}
if (scenarioExclusionPatterns() != null) {
scenarioExclusionPatterns().forEach(e -> e.validate());
}
}
private static final ClientLogger LOGGER = new ClientLogger(FusionAlertRuleProperties.class);
/**
* {@inheritDoc}
*/
@Override
public JsonWriter toJson(JsonWriter jsonWriter) throws IOException {
jsonWriter.writeStartObject();
jsonWriter.writeStringField("alertRuleTemplateName", this.alertRuleTemplateName);
jsonWriter.writeBooleanField("enabled", this.enabled);
jsonWriter.writeArrayField("sourceSettings", this.sourceSettings,
(writer, element) -> writer.writeJson(element));
jsonWriter.writeArrayField("scenarioExclusionPatterns", this.scenarioExclusionPatterns,
(writer, element) -> writer.writeJson(element));
return jsonWriter.writeEndObject();
}
/**
* Reads an instance of FusionAlertRuleProperties from the JsonReader.
*
* @param jsonReader The JsonReader being read.
* @return An instance of FusionAlertRuleProperties 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 FusionAlertRuleProperties.
*/
public static FusionAlertRuleProperties fromJson(JsonReader jsonReader) throws IOException {
return jsonReader.readObject(reader -> {
FusionAlertRuleProperties deserializedFusionAlertRuleProperties = new FusionAlertRuleProperties();
while (reader.nextToken() != JsonToken.END_OBJECT) {
String fieldName = reader.getFieldName();
reader.nextToken();
if ("alertRuleTemplateName".equals(fieldName)) {
deserializedFusionAlertRuleProperties.alertRuleTemplateName = reader.getString();
} else if ("enabled".equals(fieldName)) {
deserializedFusionAlertRuleProperties.enabled = reader.getBoolean();
} else if ("description".equals(fieldName)) {
deserializedFusionAlertRuleProperties.description = reader.getString();
} else if ("displayName".equals(fieldName)) {
deserializedFusionAlertRuleProperties.displayName = reader.getString();
} else if ("sourceSettings".equals(fieldName)) {
List sourceSettings
= reader.readArray(reader1 -> FusionSourceSettings.fromJson(reader1));
deserializedFusionAlertRuleProperties.sourceSettings = sourceSettings;
} else if ("scenarioExclusionPatterns".equals(fieldName)) {
List scenarioExclusionPatterns
= reader.readArray(reader1 -> FusionScenarioExclusionPattern.fromJson(reader1));
deserializedFusionAlertRuleProperties.scenarioExclusionPatterns = scenarioExclusionPatterns;
} else if ("lastModifiedUtc".equals(fieldName)) {
deserializedFusionAlertRuleProperties.lastModifiedUtc = reader
.getNullable(nonNullReader -> CoreUtils.parseBestOffsetDateTime(nonNullReader.getString()));
} else if ("severity".equals(fieldName)) {
deserializedFusionAlertRuleProperties.severity = AlertSeverity.fromString(reader.getString());
} else if ("tactics".equals(fieldName)) {
List tactics
= reader.readArray(reader1 -> AttackTactic.fromString(reader1.getString()));
deserializedFusionAlertRuleProperties.tactics = tactics;
} else if ("techniques".equals(fieldName)) {
List techniques = reader.readArray(reader1 -> reader1.getString());
deserializedFusionAlertRuleProperties.techniques = techniques;
} else {
reader.skipChildren();
}
}
return deserializedFusionAlertRuleProperties;
});
}
}