com.azure.resourcemanager.security.fluent.models.AlertsSuppressionRuleProperties Maven / Gradle / Ivy
// 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.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.security.models.RuleState;
import com.azure.resourcemanager.security.models.SuppressionAlertsScope;
import java.io.IOException;
import java.time.OffsetDateTime;
import java.time.format.DateTimeFormatter;
/**
* describes AlertsSuppressionRule properties.
*/
@Fluent
public final class AlertsSuppressionRuleProperties implements JsonSerializable {
/*
* Type of the alert to automatically suppress. For all alert types, use '*'
*/
private String alertType;
/*
* The last time this rule was modified
*/
private OffsetDateTime lastModifiedUtc;
/*
* Expiration date of the rule, if value is not provided or provided as null there will no expiration at all
*/
private OffsetDateTime expirationDateUtc;
/*
* The reason for dismissing the alert
*/
private String reason;
/*
* Possible states of the rule
*/
private RuleState state;
/*
* Any comment regarding the rule
*/
private String comment;
/*
* The suppression conditions
*/
private SuppressionAlertsScope suppressionAlertsScope;
/**
* Creates an instance of AlertsSuppressionRuleProperties class.
*/
public AlertsSuppressionRuleProperties() {
}
/**
* Get the alertType property: Type of the alert to automatically suppress. For all alert types, use '*'.
*
* @return the alertType value.
*/
public String alertType() {
return this.alertType;
}
/**
* Set the alertType property: Type of the alert to automatically suppress. For all alert types, use '*'.
*
* @param alertType the alertType value to set.
* @return the AlertsSuppressionRuleProperties object itself.
*/
public AlertsSuppressionRuleProperties withAlertType(String alertType) {
this.alertType = alertType;
return this;
}
/**
* Get the lastModifiedUtc property: The last time this rule was modified.
*
* @return the lastModifiedUtc value.
*/
public OffsetDateTime lastModifiedUtc() {
return this.lastModifiedUtc;
}
/**
* Get the expirationDateUtc property: Expiration date of the rule, if value is not provided or provided as null
* there will no expiration at all.
*
* @return the expirationDateUtc value.
*/
public OffsetDateTime expirationDateUtc() {
return this.expirationDateUtc;
}
/**
* Set the expirationDateUtc property: Expiration date of the rule, if value is not provided or provided as null
* there will no expiration at all.
*
* @param expirationDateUtc the expirationDateUtc value to set.
* @return the AlertsSuppressionRuleProperties object itself.
*/
public AlertsSuppressionRuleProperties withExpirationDateUtc(OffsetDateTime expirationDateUtc) {
this.expirationDateUtc = expirationDateUtc;
return this;
}
/**
* Get the reason property: The reason for dismissing the alert.
*
* @return the reason value.
*/
public String reason() {
return this.reason;
}
/**
* Set the reason property: The reason for dismissing the alert.
*
* @param reason the reason value to set.
* @return the AlertsSuppressionRuleProperties object itself.
*/
public AlertsSuppressionRuleProperties withReason(String reason) {
this.reason = reason;
return this;
}
/**
* Get the state property: Possible states of the rule.
*
* @return the state value.
*/
public RuleState state() {
return this.state;
}
/**
* Set the state property: Possible states of the rule.
*
* @param state the state value to set.
* @return the AlertsSuppressionRuleProperties object itself.
*/
public AlertsSuppressionRuleProperties withState(RuleState state) {
this.state = state;
return this;
}
/**
* Get the comment property: Any comment regarding the rule.
*
* @return the comment value.
*/
public String comment() {
return this.comment;
}
/**
* Set the comment property: Any comment regarding the rule.
*
* @param comment the comment value to set.
* @return the AlertsSuppressionRuleProperties object itself.
*/
public AlertsSuppressionRuleProperties withComment(String comment) {
this.comment = comment;
return this;
}
/**
* Get the suppressionAlertsScope property: The suppression conditions.
*
* @return the suppressionAlertsScope value.
*/
public SuppressionAlertsScope suppressionAlertsScope() {
return this.suppressionAlertsScope;
}
/**
* Set the suppressionAlertsScope property: The suppression conditions.
*
* @param suppressionAlertsScope the suppressionAlertsScope value to set.
* @return the AlertsSuppressionRuleProperties object itself.
*/
public AlertsSuppressionRuleProperties withSuppressionAlertsScope(SuppressionAlertsScope suppressionAlertsScope) {
this.suppressionAlertsScope = suppressionAlertsScope;
return this;
}
/**
* Validates the instance.
*
* @throws IllegalArgumentException thrown if the instance is not valid.
*/
public void validate() {
if (alertType() == null) {
throw LOGGER.atError()
.log(new IllegalArgumentException(
"Missing required property alertType in model AlertsSuppressionRuleProperties"));
}
if (reason() == null) {
throw LOGGER.atError()
.log(new IllegalArgumentException(
"Missing required property reason in model AlertsSuppressionRuleProperties"));
}
if (state() == null) {
throw LOGGER.atError()
.log(new IllegalArgumentException(
"Missing required property state in model AlertsSuppressionRuleProperties"));
}
if (suppressionAlertsScope() != null) {
suppressionAlertsScope().validate();
}
}
private static final ClientLogger LOGGER = new ClientLogger(AlertsSuppressionRuleProperties.class);
/**
* {@inheritDoc}
*/
@Override
public JsonWriter toJson(JsonWriter jsonWriter) throws IOException {
jsonWriter.writeStartObject();
jsonWriter.writeStringField("alertType", this.alertType);
jsonWriter.writeStringField("reason", this.reason);
jsonWriter.writeStringField("state", this.state == null ? null : this.state.toString());
jsonWriter.writeStringField("expirationDateUtc",
this.expirationDateUtc == null
? null
: DateTimeFormatter.ISO_OFFSET_DATE_TIME.format(this.expirationDateUtc));
jsonWriter.writeStringField("comment", this.comment);
jsonWriter.writeJsonField("suppressionAlertsScope", this.suppressionAlertsScope);
return jsonWriter.writeEndObject();
}
/**
* Reads an instance of AlertsSuppressionRuleProperties from the JsonReader.
*
* @param jsonReader The JsonReader being read.
* @return An instance of AlertsSuppressionRuleProperties 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 AlertsSuppressionRuleProperties.
*/
public static AlertsSuppressionRuleProperties fromJson(JsonReader jsonReader) throws IOException {
return jsonReader.readObject(reader -> {
AlertsSuppressionRuleProperties deserializedAlertsSuppressionRuleProperties
= new AlertsSuppressionRuleProperties();
while (reader.nextToken() != JsonToken.END_OBJECT) {
String fieldName = reader.getFieldName();
reader.nextToken();
if ("alertType".equals(fieldName)) {
deserializedAlertsSuppressionRuleProperties.alertType = reader.getString();
} else if ("reason".equals(fieldName)) {
deserializedAlertsSuppressionRuleProperties.reason = reader.getString();
} else if ("state".equals(fieldName)) {
deserializedAlertsSuppressionRuleProperties.state = RuleState.fromString(reader.getString());
} else if ("lastModifiedUtc".equals(fieldName)) {
deserializedAlertsSuppressionRuleProperties.lastModifiedUtc = reader
.getNullable(nonNullReader -> CoreUtils.parseBestOffsetDateTime(nonNullReader.getString()));
} else if ("expirationDateUtc".equals(fieldName)) {
deserializedAlertsSuppressionRuleProperties.expirationDateUtc = reader
.getNullable(nonNullReader -> CoreUtils.parseBestOffsetDateTime(nonNullReader.getString()));
} else if ("comment".equals(fieldName)) {
deserializedAlertsSuppressionRuleProperties.comment = reader.getString();
} else if ("suppressionAlertsScope".equals(fieldName)) {
deserializedAlertsSuppressionRuleProperties.suppressionAlertsScope
= SuppressionAlertsScope.fromJson(reader);
} else {
reader.skipChildren();
}
}
return deserializedAlertsSuppressionRuleProperties;
});
}
}
© 2015 - 2025 Weber Informatics LLC | Privacy Policy