
com.azure.resourcemanager.network.models.ActiveSecurityAdminRule 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.JsonToken;
import com.azure.json.JsonWriter;
import com.azure.resourcemanager.network.fluent.models.AdminPropertiesFormat;
import java.io.IOException;
import java.time.OffsetDateTime;
import java.time.format.DateTimeFormatter;
import java.util.List;
/**
* Network admin rule.
*/
@Fluent
public final class ActiveSecurityAdminRule extends ActiveBaseSecurityAdminRule {
/*
* Whether the rule is custom or default.
*/
private EffectiveAdminRuleKind kind = EffectiveAdminRuleKind.CUSTOM;
/*
* Indicates the properties of the security admin rule
*/
private AdminPropertiesFormat innerProperties;
/**
* Creates an instance of ActiveSecurityAdminRule class.
*/
public ActiveSecurityAdminRule() {
}
/**
* Get the kind property: Whether the rule is custom or default.
*
* @return the kind value.
*/
@Override
public EffectiveAdminRuleKind kind() {
return this.kind;
}
/**
* Get the innerProperties property: Indicates the properties of the security admin rule.
*
* @return the innerProperties value.
*/
private AdminPropertiesFormat innerProperties() {
return this.innerProperties;
}
/**
* {@inheritDoc}
*/
@Override
public ActiveSecurityAdminRule withId(String id) {
super.withId(id);
return this;
}
/**
* {@inheritDoc}
*/
@Override
public ActiveSecurityAdminRule withCommitTime(OffsetDateTime commitTime) {
super.withCommitTime(commitTime);
return this;
}
/**
* {@inheritDoc}
*/
@Override
public ActiveSecurityAdminRule withRegion(String region) {
super.withRegion(region);
return this;
}
/**
* {@inheritDoc}
*/
@Override
public ActiveSecurityAdminRule withConfigurationDescription(String configurationDescription) {
super.withConfigurationDescription(configurationDescription);
return this;
}
/**
* {@inheritDoc}
*/
@Override
public ActiveSecurityAdminRule withRuleCollectionDescription(String ruleCollectionDescription) {
super.withRuleCollectionDescription(ruleCollectionDescription);
return this;
}
/**
* {@inheritDoc}
*/
@Override
public ActiveSecurityAdminRule
withRuleCollectionAppliesToGroups(List ruleCollectionAppliesToGroups) {
super.withRuleCollectionAppliesToGroups(ruleCollectionAppliesToGroups);
return this;
}
/**
* {@inheritDoc}
*/
@Override
public ActiveSecurityAdminRule withRuleGroups(List ruleGroups) {
super.withRuleGroups(ruleGroups);
return this;
}
/**
* Get the description property: A description for this rule. Restricted to 140 chars.
*
* @return the description value.
*/
public String description() {
return this.innerProperties() == null ? null : this.innerProperties().description();
}
/**
* Set the description property: A description for this rule. Restricted to 140 chars.
*
* @param description the description value to set.
* @return the ActiveSecurityAdminRule object itself.
*/
public ActiveSecurityAdminRule withDescription(String description) {
if (this.innerProperties() == null) {
this.innerProperties = new AdminPropertiesFormat();
}
this.innerProperties().withDescription(description);
return this;
}
/**
* Get the protocol property: Network protocol this rule applies to.
*
* @return the protocol value.
*/
public SecurityConfigurationRuleProtocol protocol() {
return this.innerProperties() == null ? null : this.innerProperties().protocol();
}
/**
* Set the protocol property: Network protocol this rule applies to.
*
* @param protocol the protocol value to set.
* @return the ActiveSecurityAdminRule object itself.
*/
public ActiveSecurityAdminRule withProtocol(SecurityConfigurationRuleProtocol protocol) {
if (this.innerProperties() == null) {
this.innerProperties = new AdminPropertiesFormat();
}
this.innerProperties().withProtocol(protocol);
return this;
}
/**
* Get the sources property: The CIDR or source IP ranges.
*
* @return the sources value.
*/
public List sources() {
return this.innerProperties() == null ? null : this.innerProperties().sources();
}
/**
* Set the sources property: The CIDR or source IP ranges.
*
* @param sources the sources value to set.
* @return the ActiveSecurityAdminRule object itself.
*/
public ActiveSecurityAdminRule withSources(List sources) {
if (this.innerProperties() == null) {
this.innerProperties = new AdminPropertiesFormat();
}
this.innerProperties().withSources(sources);
return this;
}
/**
* Get the destinations property: The destination address prefixes. CIDR or destination IP ranges.
*
* @return the destinations value.
*/
public List destinations() {
return this.innerProperties() == null ? null : this.innerProperties().destinations();
}
/**
* Set the destinations property: The destination address prefixes. CIDR or destination IP ranges.
*
* @param destinations the destinations value to set.
* @return the ActiveSecurityAdminRule object itself.
*/
public ActiveSecurityAdminRule withDestinations(List destinations) {
if (this.innerProperties() == null) {
this.innerProperties = new AdminPropertiesFormat();
}
this.innerProperties().withDestinations(destinations);
return this;
}
/**
* Get the sourcePortRanges property: The source port ranges.
*
* @return the sourcePortRanges value.
*/
public List sourcePortRanges() {
return this.innerProperties() == null ? null : this.innerProperties().sourcePortRanges();
}
/**
* Set the sourcePortRanges property: The source port ranges.
*
* @param sourcePortRanges the sourcePortRanges value to set.
* @return the ActiveSecurityAdminRule object itself.
*/
public ActiveSecurityAdminRule withSourcePortRanges(List sourcePortRanges) {
if (this.innerProperties() == null) {
this.innerProperties = new AdminPropertiesFormat();
}
this.innerProperties().withSourcePortRanges(sourcePortRanges);
return this;
}
/**
* Get the destinationPortRanges property: The destination port ranges.
*
* @return the destinationPortRanges value.
*/
public List destinationPortRanges() {
return this.innerProperties() == null ? null : this.innerProperties().destinationPortRanges();
}
/**
* Set the destinationPortRanges property: The destination port ranges.
*
* @param destinationPortRanges the destinationPortRanges value to set.
* @return the ActiveSecurityAdminRule object itself.
*/
public ActiveSecurityAdminRule withDestinationPortRanges(List destinationPortRanges) {
if (this.innerProperties() == null) {
this.innerProperties = new AdminPropertiesFormat();
}
this.innerProperties().withDestinationPortRanges(destinationPortRanges);
return this;
}
/**
* Get the access property: Indicates the access allowed for this particular rule.
*
* @return the access value.
*/
public SecurityConfigurationRuleAccess access() {
return this.innerProperties() == null ? null : this.innerProperties().access();
}
/**
* Set the access property: Indicates the access allowed for this particular rule.
*
* @param access the access value to set.
* @return the ActiveSecurityAdminRule object itself.
*/
public ActiveSecurityAdminRule withAccess(SecurityConfigurationRuleAccess access) {
if (this.innerProperties() == null) {
this.innerProperties = new AdminPropertiesFormat();
}
this.innerProperties().withAccess(access);
return this;
}
/**
* Get the priority property: The priority of the rule. The value can be between 1 and 4096. The priority number
* must be unique for each rule in the collection. The lower the priority number, the higher the priority of the
* rule.
*
* @return the priority value.
*/
public Integer priority() {
return this.innerProperties() == null ? null : this.innerProperties().priority();
}
/**
* Set the priority property: The priority of the rule. The value can be between 1 and 4096. The priority number
* must be unique for each rule in the collection. The lower the priority number, the higher the priority of the
* rule.
*
* @param priority the priority value to set.
* @return the ActiveSecurityAdminRule object itself.
*/
public ActiveSecurityAdminRule withPriority(Integer priority) {
if (this.innerProperties() == null) {
this.innerProperties = new AdminPropertiesFormat();
}
this.innerProperties().withPriority(priority);
return this;
}
/**
* Get the direction property: Indicates if the traffic matched against the rule in inbound or outbound.
*
* @return the direction value.
*/
public SecurityConfigurationRuleDirection direction() {
return this.innerProperties() == null ? null : this.innerProperties().direction();
}
/**
* Set the direction property: Indicates if the traffic matched against the rule in inbound or outbound.
*
* @param direction the direction value to set.
* @return the ActiveSecurityAdminRule object itself.
*/
public ActiveSecurityAdminRule withDirection(SecurityConfigurationRuleDirection direction) {
if (this.innerProperties() == null) {
this.innerProperties = new AdminPropertiesFormat();
}
this.innerProperties().withDirection(direction);
return this;
}
/**
* Get the provisioningState property: The provisioning state of the resource.
*
* @return the provisioningState value.
*/
public ProvisioningState provisioningState() {
return this.innerProperties() == null ? null : this.innerProperties().provisioningState();
}
/**
* Get the resourceGuid property: Unique identifier for this resource.
*
* @return the resourceGuid value.
*/
public String resourceGuid() {
return this.innerProperties() == null ? null : this.innerProperties().resourceGuid();
}
/**
* Validates the instance.
*
* @throws IllegalArgumentException thrown if the instance is not valid.
*/
@Override
public void validate() {
if (innerProperties() != null) {
innerProperties().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("id", id());
jsonWriter.writeStringField("commitTime",
commitTime() == null ? null : DateTimeFormatter.ISO_OFFSET_DATE_TIME.format(commitTime()));
jsonWriter.writeStringField("region", region());
jsonWriter.writeStringField("configurationDescription", configurationDescription());
jsonWriter.writeStringField("ruleCollectionDescription", ruleCollectionDescription());
jsonWriter.writeArrayField("ruleCollectionAppliesToGroups", ruleCollectionAppliesToGroups(),
(writer, element) -> writer.writeJson(element));
jsonWriter.writeArrayField("ruleGroups", ruleGroups(), (writer, element) -> writer.writeJson(element));
jsonWriter.writeStringField("kind", this.kind == null ? null : this.kind.toString());
jsonWriter.writeJsonField("properties", this.innerProperties);
return jsonWriter.writeEndObject();
}
/**
* Reads an instance of ActiveSecurityAdminRule from the JsonReader.
*
* @param jsonReader The JsonReader being read.
* @return An instance of ActiveSecurityAdminRule 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 ActiveSecurityAdminRule.
*/
public static ActiveSecurityAdminRule fromJson(JsonReader jsonReader) throws IOException {
return jsonReader.readObject(reader -> {
ActiveSecurityAdminRule deserializedActiveSecurityAdminRule = new ActiveSecurityAdminRule();
while (reader.nextToken() != JsonToken.END_OBJECT) {
String fieldName = reader.getFieldName();
reader.nextToken();
if ("id".equals(fieldName)) {
deserializedActiveSecurityAdminRule.withId(reader.getString());
} else if ("commitTime".equals(fieldName)) {
deserializedActiveSecurityAdminRule.withCommitTime(reader
.getNullable(nonNullReader -> CoreUtils.parseBestOffsetDateTime(nonNullReader.getString())));
} else if ("region".equals(fieldName)) {
deserializedActiveSecurityAdminRule.withRegion(reader.getString());
} else if ("configurationDescription".equals(fieldName)) {
deserializedActiveSecurityAdminRule.withConfigurationDescription(reader.getString());
} else if ("ruleCollectionDescription".equals(fieldName)) {
deserializedActiveSecurityAdminRule.withRuleCollectionDescription(reader.getString());
} else if ("ruleCollectionAppliesToGroups".equals(fieldName)) {
List ruleCollectionAppliesToGroups
= reader.readArray(reader1 -> NetworkManagerSecurityGroupItem.fromJson(reader1));
deserializedActiveSecurityAdminRule
.withRuleCollectionAppliesToGroups(ruleCollectionAppliesToGroups);
} else if ("ruleGroups".equals(fieldName)) {
List ruleGroups
= reader.readArray(reader1 -> ConfigurationGroup.fromJson(reader1));
deserializedActiveSecurityAdminRule.withRuleGroups(ruleGroups);
} else if ("kind".equals(fieldName)) {
deserializedActiveSecurityAdminRule.kind = EffectiveAdminRuleKind.fromString(reader.getString());
} else if ("properties".equals(fieldName)) {
deserializedActiveSecurityAdminRule.innerProperties = AdminPropertiesFormat.fromJson(reader);
} else {
reader.skipChildren();
}
}
return deserializedActiveSecurityAdminRule;
});
}
}
© 2015 - 2025 Weber Informatics LLC | Privacy Policy