
com.azure.resourcemanager.network.models.ActiveBaseSecurityAdminRule 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.network.models;
import com.azure.core.annotation.Fluent;
import com.azure.core.util.CoreUtils;
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.OffsetDateTime;
import java.time.format.DateTimeFormatter;
import java.util.List;
/**
* Network base admin rule.
*/
@Fluent
public class ActiveBaseSecurityAdminRule implements JsonSerializable {
/*
* Whether the rule is custom or default.
*/
private EffectiveAdminRuleKind kind = EffectiveAdminRuleKind.fromString("ActiveBaseSecurityAdminRule");
/*
* Resource ID.
*/
private String id;
/*
* Deployment time string.
*/
private OffsetDateTime commitTime;
/*
* Deployment region.
*/
private String region;
/*
* A description of the security admin configuration.
*/
private String configurationDescription;
/*
* A description of the rule collection.
*/
private String ruleCollectionDescription;
/*
* Groups for rule collection
*/
private List ruleCollectionAppliesToGroups;
/*
* Effective configuration groups.
*/
private List ruleGroups;
/**
* Creates an instance of ActiveBaseSecurityAdminRule class.
*/
public ActiveBaseSecurityAdminRule() {
}
/**
* Get the kind property: Whether the rule is custom or default.
*
* @return the kind value.
*/
public EffectiveAdminRuleKind kind() {
return this.kind;
}
/**
* Get the id property: Resource ID.
*
* @return the id value.
*/
public String id() {
return this.id;
}
/**
* Set the id property: Resource ID.
*
* @param id the id value to set.
* @return the ActiveBaseSecurityAdminRule object itself.
*/
public ActiveBaseSecurityAdminRule withId(String id) {
this.id = id;
return this;
}
/**
* Get the commitTime property: Deployment time string.
*
* @return the commitTime value.
*/
public OffsetDateTime commitTime() {
return this.commitTime;
}
/**
* Set the commitTime property: Deployment time string.
*
* @param commitTime the commitTime value to set.
* @return the ActiveBaseSecurityAdminRule object itself.
*/
public ActiveBaseSecurityAdminRule withCommitTime(OffsetDateTime commitTime) {
this.commitTime = commitTime;
return this;
}
/**
* Get the region property: Deployment region.
*
* @return the region value.
*/
public String region() {
return this.region;
}
/**
* Set the region property: Deployment region.
*
* @param region the region value to set.
* @return the ActiveBaseSecurityAdminRule object itself.
*/
public ActiveBaseSecurityAdminRule withRegion(String region) {
this.region = region;
return this;
}
/**
* Get the configurationDescription property: A description of the security admin configuration.
*
* @return the configurationDescription value.
*/
public String configurationDescription() {
return this.configurationDescription;
}
/**
* Set the configurationDescription property: A description of the security admin configuration.
*
* @param configurationDescription the configurationDescription value to set.
* @return the ActiveBaseSecurityAdminRule object itself.
*/
public ActiveBaseSecurityAdminRule withConfigurationDescription(String configurationDescription) {
this.configurationDescription = configurationDescription;
return this;
}
/**
* Get the ruleCollectionDescription property: A description of the rule collection.
*
* @return the ruleCollectionDescription value.
*/
public String ruleCollectionDescription() {
return this.ruleCollectionDescription;
}
/**
* Set the ruleCollectionDescription property: A description of the rule collection.
*
* @param ruleCollectionDescription the ruleCollectionDescription value to set.
* @return the ActiveBaseSecurityAdminRule object itself.
*/
public ActiveBaseSecurityAdminRule withRuleCollectionDescription(String ruleCollectionDescription) {
this.ruleCollectionDescription = ruleCollectionDescription;
return this;
}
/**
* Get the ruleCollectionAppliesToGroups property: Groups for rule collection.
*
* @return the ruleCollectionAppliesToGroups value.
*/
public List ruleCollectionAppliesToGroups() {
return this.ruleCollectionAppliesToGroups;
}
/**
* Set the ruleCollectionAppliesToGroups property: Groups for rule collection.
*
* @param ruleCollectionAppliesToGroups the ruleCollectionAppliesToGroups value to set.
* @return the ActiveBaseSecurityAdminRule object itself.
*/
public ActiveBaseSecurityAdminRule
withRuleCollectionAppliesToGroups(List ruleCollectionAppliesToGroups) {
this.ruleCollectionAppliesToGroups = ruleCollectionAppliesToGroups;
return this;
}
/**
* Get the ruleGroups property: Effective configuration groups.
*
* @return the ruleGroups value.
*/
public List ruleGroups() {
return this.ruleGroups;
}
/**
* Set the ruleGroups property: Effective configuration groups.
*
* @param ruleGroups the ruleGroups value to set.
* @return the ActiveBaseSecurityAdminRule object itself.
*/
public ActiveBaseSecurityAdminRule withRuleGroups(List ruleGroups) {
this.ruleGroups = ruleGroups;
return this;
}
/**
* Validates the instance.
*
* @throws IllegalArgumentException thrown if the instance is not valid.
*/
public void validate() {
if (ruleCollectionAppliesToGroups() != null) {
ruleCollectionAppliesToGroups().forEach(e -> e.validate());
}
if (ruleGroups() != null) {
ruleGroups().forEach(e -> e.validate());
}
}
/**
* {@inheritDoc}
*/
@Override
public JsonWriter toJson(JsonWriter jsonWriter) throws IOException {
jsonWriter.writeStartObject();
jsonWriter.writeStringField("kind", this.kind == null ? null : this.kind.toString());
jsonWriter.writeStringField("id", this.id);
jsonWriter.writeStringField("commitTime",
this.commitTime == null ? null : DateTimeFormatter.ISO_OFFSET_DATE_TIME.format(this.commitTime));
jsonWriter.writeStringField("region", this.region);
jsonWriter.writeStringField("configurationDescription", this.configurationDescription);
jsonWriter.writeStringField("ruleCollectionDescription", this.ruleCollectionDescription);
jsonWriter.writeArrayField("ruleCollectionAppliesToGroups", this.ruleCollectionAppliesToGroups,
(writer, element) -> writer.writeJson(element));
jsonWriter.writeArrayField("ruleGroups", this.ruleGroups, (writer, element) -> writer.writeJson(element));
return jsonWriter.writeEndObject();
}
/**
* Reads an instance of ActiveBaseSecurityAdminRule from the JsonReader.
*
* @param jsonReader The JsonReader being read.
* @return An instance of ActiveBaseSecurityAdminRule if the JsonReader was pointing to an instance of it, or null
* if it was pointing to JSON null.
* @throws IOException If an error occurs while reading the ActiveBaseSecurityAdminRule.
*/
public static ActiveBaseSecurityAdminRule 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 ("kind".equals(fieldName)) {
discriminatorValue = readerToUse.getString();
break;
} else {
readerToUse.skipChildren();
}
}
// Use the discriminator value to determine which subtype should be deserialized.
if ("Custom".equals(discriminatorValue)) {
return ActiveSecurityAdminRule.fromJson(readerToUse.reset());
} else if ("Default".equals(discriminatorValue)) {
return ActiveDefaultSecurityAdminRule.fromJson(readerToUse.reset());
} else {
return fromJsonKnownDiscriminator(readerToUse.reset());
}
}
});
}
static ActiveBaseSecurityAdminRule fromJsonKnownDiscriminator(JsonReader jsonReader) throws IOException {
return jsonReader.readObject(reader -> {
ActiveBaseSecurityAdminRule deserializedActiveBaseSecurityAdminRule = new ActiveBaseSecurityAdminRule();
while (reader.nextToken() != JsonToken.END_OBJECT) {
String fieldName = reader.getFieldName();
reader.nextToken();
if ("kind".equals(fieldName)) {
deserializedActiveBaseSecurityAdminRule.kind
= EffectiveAdminRuleKind.fromString(reader.getString());
} else if ("id".equals(fieldName)) {
deserializedActiveBaseSecurityAdminRule.id = reader.getString();
} else if ("commitTime".equals(fieldName)) {
deserializedActiveBaseSecurityAdminRule.commitTime = reader
.getNullable(nonNullReader -> CoreUtils.parseBestOffsetDateTime(nonNullReader.getString()));
} else if ("region".equals(fieldName)) {
deserializedActiveBaseSecurityAdminRule.region = reader.getString();
} else if ("configurationDescription".equals(fieldName)) {
deserializedActiveBaseSecurityAdminRule.configurationDescription = reader.getString();
} else if ("ruleCollectionDescription".equals(fieldName)) {
deserializedActiveBaseSecurityAdminRule.ruleCollectionDescription = reader.getString();
} else if ("ruleCollectionAppliesToGroups".equals(fieldName)) {
List ruleCollectionAppliesToGroups
= reader.readArray(reader1 -> NetworkManagerSecurityGroupItem.fromJson(reader1));
deserializedActiveBaseSecurityAdminRule.ruleCollectionAppliesToGroups
= ruleCollectionAppliesToGroups;
} else if ("ruleGroups".equals(fieldName)) {
List ruleGroups
= reader.readArray(reader1 -> ConfigurationGroup.fromJson(reader1));
deserializedActiveBaseSecurityAdminRule.ruleGroups = ruleGroups;
} else {
reader.skipChildren();
}
}
return deserializedActiveBaseSecurityAdminRule;
});
}
}
© 2015 - 2025 Weber Informatics LLC | Privacy Policy