com.azure.resourcemanager.dnsresolver.fluent.models.DnsSecurityRulePatchProperties Maven / Gradle / Ivy
Go to download
Show more of this group Show more artifacts with this name
Show all versions of azure-resourcemanager-dnsresolver Show documentation
Show all versions of azure-resourcemanager-dnsresolver Show documentation
This package contains Microsoft Azure SDK for DnsResolver Management SDK. For documentation on how to use this package, please see https://aka.ms/azsdk/java/mgmt. The DNS Resolver Management Client. Package tag package-2022-07.
// Copyright (c) Microsoft Corporation. All rights reserved.
// Licensed under the MIT License.
// Code generated by Microsoft (R) AutoRest Code Generator.
package com.azure.resourcemanager.dnsresolver.fluent.models;
import com.azure.core.annotation.Fluent;
import com.azure.core.management.SubResource;
import com.azure.json.JsonReader;
import com.azure.json.JsonSerializable;
import com.azure.json.JsonToken;
import com.azure.json.JsonWriter;
import com.azure.resourcemanager.dnsresolver.models.DnsSecurityRuleAction;
import com.azure.resourcemanager.dnsresolver.models.DnsSecurityRuleState;
import java.io.IOException;
import java.util.List;
/**
* Represents the updatable properties of a DNS security rule.
*/
@Fluent
public final class DnsSecurityRulePatchProperties implements JsonSerializable {
/*
* The action to take on DNS requests that match the DNS security rule.
*/
private DnsSecurityRuleAction action;
/*
* DNS resolver policy domains lists that the DNS security rule applies to.
*/
private List dnsResolverDomainLists;
/*
* The state of DNS security rule.
*/
private DnsSecurityRuleState dnsSecurityRuleState;
/*
* The priority of the DNS security rule.
*/
private Integer priority;
/**
* Creates an instance of DnsSecurityRulePatchProperties class.
*/
public DnsSecurityRulePatchProperties() {
}
/**
* Get the action property: The action to take on DNS requests that match the DNS security rule.
*
* @return the action value.
*/
public DnsSecurityRuleAction action() {
return this.action;
}
/**
* Set the action property: The action to take on DNS requests that match the DNS security rule.
*
* @param action the action value to set.
* @return the DnsSecurityRulePatchProperties object itself.
*/
public DnsSecurityRulePatchProperties withAction(DnsSecurityRuleAction action) {
this.action = action;
return this;
}
/**
* Get the dnsResolverDomainLists property: DNS resolver policy domains lists that the DNS security rule applies to.
*
* @return the dnsResolverDomainLists value.
*/
public List dnsResolverDomainLists() {
return this.dnsResolverDomainLists;
}
/**
* Set the dnsResolverDomainLists property: DNS resolver policy domains lists that the DNS security rule applies to.
*
* @param dnsResolverDomainLists the dnsResolverDomainLists value to set.
* @return the DnsSecurityRulePatchProperties object itself.
*/
public DnsSecurityRulePatchProperties withDnsResolverDomainLists(List dnsResolverDomainLists) {
this.dnsResolverDomainLists = dnsResolverDomainLists;
return this;
}
/**
* Get the dnsSecurityRuleState property: The state of DNS security rule.
*
* @return the dnsSecurityRuleState value.
*/
public DnsSecurityRuleState dnsSecurityRuleState() {
return this.dnsSecurityRuleState;
}
/**
* Set the dnsSecurityRuleState property: The state of DNS security rule.
*
* @param dnsSecurityRuleState the dnsSecurityRuleState value to set.
* @return the DnsSecurityRulePatchProperties object itself.
*/
public DnsSecurityRulePatchProperties withDnsSecurityRuleState(DnsSecurityRuleState dnsSecurityRuleState) {
this.dnsSecurityRuleState = dnsSecurityRuleState;
return this;
}
/**
* Get the priority property: The priority of the DNS security rule.
*
* @return the priority value.
*/
public Integer priority() {
return this.priority;
}
/**
* Set the priority property: The priority of the DNS security rule.
*
* @param priority the priority value to set.
* @return the DnsSecurityRulePatchProperties object itself.
*/
public DnsSecurityRulePatchProperties withPriority(Integer priority) {
this.priority = priority;
return this;
}
/**
* Validates the instance.
*
* @throws IllegalArgumentException thrown if the instance is not valid.
*/
public void validate() {
if (action() != null) {
action().validate();
}
}
/**
* {@inheritDoc}
*/
@Override
public JsonWriter toJson(JsonWriter jsonWriter) throws IOException {
jsonWriter.writeStartObject();
jsonWriter.writeJsonField("action", this.action);
jsonWriter.writeArrayField("dnsResolverDomainLists", this.dnsResolverDomainLists,
(writer, element) -> writer.writeJson(element));
jsonWriter.writeStringField("dnsSecurityRuleState",
this.dnsSecurityRuleState == null ? null : this.dnsSecurityRuleState.toString());
jsonWriter.writeNumberField("priority", this.priority);
return jsonWriter.writeEndObject();
}
/**
* Reads an instance of DnsSecurityRulePatchProperties from the JsonReader.
*
* @param jsonReader The JsonReader being read.
* @return An instance of DnsSecurityRulePatchProperties 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 DnsSecurityRulePatchProperties.
*/
public static DnsSecurityRulePatchProperties fromJson(JsonReader jsonReader) throws IOException {
return jsonReader.readObject(reader -> {
DnsSecurityRulePatchProperties deserializedDnsSecurityRulePatchProperties
= new DnsSecurityRulePatchProperties();
while (reader.nextToken() != JsonToken.END_OBJECT) {
String fieldName = reader.getFieldName();
reader.nextToken();
if ("action".equals(fieldName)) {
deserializedDnsSecurityRulePatchProperties.action = DnsSecurityRuleAction.fromJson(reader);
} else if ("dnsResolverDomainLists".equals(fieldName)) {
List dnsResolverDomainLists
= reader.readArray(reader1 -> SubResource.fromJson(reader1));
deserializedDnsSecurityRulePatchProperties.dnsResolverDomainLists = dnsResolverDomainLists;
} else if ("dnsSecurityRuleState".equals(fieldName)) {
deserializedDnsSecurityRulePatchProperties.dnsSecurityRuleState
= DnsSecurityRuleState.fromString(reader.getString());
} else if ("priority".equals(fieldName)) {
deserializedDnsSecurityRulePatchProperties.priority = reader.getNullable(JsonReader::getInt);
} else {
reader.skipChildren();
}
}
return deserializedDnsSecurityRulePatchProperties;
});
}
}