All Downloads are FREE. Search and download functionalities are using the official Maven repository.

com.azure.resourcemanager.dnsresolver.models.DnsSecurityRuleAction Maven / Gradle / Ivy

Go to download

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.

There is a newer version: 1.0.0-beta.3
Show 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.dnsresolver.models;

import com.azure.core.annotation.Fluent;
import com.azure.json.JsonReader;
import com.azure.json.JsonSerializable;
import com.azure.json.JsonToken;
import com.azure.json.JsonWriter;
import java.io.IOException;

/**
 * The action to take on DNS requests that match the DNS security rule.
 */
@Fluent
public final class DnsSecurityRuleAction implements JsonSerializable {
    /*
     * The type of action to take.
     */
    private ActionType actionType;

    /*
     * The response code for block actions.
     */
    private BlockResponseCode blockResponseCode;

    /**
     * Creates an instance of DnsSecurityRuleAction class.
     */
    public DnsSecurityRuleAction() {
    }

    /**
     * Get the actionType property: The type of action to take.
     * 
     * @return the actionType value.
     */
    public ActionType actionType() {
        return this.actionType;
    }

    /**
     * Set the actionType property: The type of action to take.
     * 
     * @param actionType the actionType value to set.
     * @return the DnsSecurityRuleAction object itself.
     */
    public DnsSecurityRuleAction withActionType(ActionType actionType) {
        this.actionType = actionType;
        return this;
    }

    /**
     * Get the blockResponseCode property: The response code for block actions.
     * 
     * @return the blockResponseCode value.
     */
    public BlockResponseCode blockResponseCode() {
        return this.blockResponseCode;
    }

    /**
     * Set the blockResponseCode property: The response code for block actions.
     * 
     * @param blockResponseCode the blockResponseCode value to set.
     * @return the DnsSecurityRuleAction object itself.
     */
    public DnsSecurityRuleAction withBlockResponseCode(BlockResponseCode blockResponseCode) {
        this.blockResponseCode = blockResponseCode;
        return this;
    }

    /**
     * Validates the instance.
     * 
     * @throws IllegalArgumentException thrown if the instance is not valid.
     */
    public void validate() {
    }

    /**
     * {@inheritDoc}
     */
    @Override
    public JsonWriter toJson(JsonWriter jsonWriter) throws IOException {
        jsonWriter.writeStartObject();
        jsonWriter.writeStringField("actionType", this.actionType == null ? null : this.actionType.toString());
        jsonWriter.writeStringField("blockResponseCode",
            this.blockResponseCode == null ? null : this.blockResponseCode.toString());
        return jsonWriter.writeEndObject();
    }

    /**
     * Reads an instance of DnsSecurityRuleAction from the JsonReader.
     * 
     * @param jsonReader The JsonReader being read.
     * @return An instance of DnsSecurityRuleAction 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 DnsSecurityRuleAction.
     */
    public static DnsSecurityRuleAction fromJson(JsonReader jsonReader) throws IOException {
        return jsonReader.readObject(reader -> {
            DnsSecurityRuleAction deserializedDnsSecurityRuleAction = new DnsSecurityRuleAction();
            while (reader.nextToken() != JsonToken.END_OBJECT) {
                String fieldName = reader.getFieldName();
                reader.nextToken();

                if ("actionType".equals(fieldName)) {
                    deserializedDnsSecurityRuleAction.actionType = ActionType.fromString(reader.getString());
                } else if ("blockResponseCode".equals(fieldName)) {
                    deserializedDnsSecurityRuleAction.blockResponseCode
                        = BlockResponseCode.fromString(reader.getString());
                } else {
                    reader.skipChildren();
                }
            }

            return deserializedDnsSecurityRuleAction;
        });
    }
}




© 2015 - 2024 Weber Informatics LLC | Privacy Policy