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

com.azure.resourcemanager.frontdoor.models.RulesEngineAction 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.frontdoor.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;
import java.util.List;

/**
 * One or more actions that will execute, modifying the request and/or response.
 */
@Fluent
public final class RulesEngineAction implements JsonSerializable {
    /*
     * A list of header actions to apply from the request from AFD to the origin.
     */
    private List requestHeaderActions;

    /*
     * A list of header actions to apply from the response from AFD to the client.
     */
    private List responseHeaderActions;

    /*
     * Override the route configuration.
     */
    private RouteConfiguration routeConfigurationOverride;

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

    /**
     * Get the requestHeaderActions property: A list of header actions to apply from the request from AFD to the origin.
     * 
     * @return the requestHeaderActions value.
     */
    public List requestHeaderActions() {
        return this.requestHeaderActions;
    }

    /**
     * Set the requestHeaderActions property: A list of header actions to apply from the request from AFD to the origin.
     * 
     * @param requestHeaderActions the requestHeaderActions value to set.
     * @return the RulesEngineAction object itself.
     */
    public RulesEngineAction withRequestHeaderActions(List requestHeaderActions) {
        this.requestHeaderActions = requestHeaderActions;
        return this;
    }

    /**
     * Get the responseHeaderActions property: A list of header actions to apply from the response from AFD to the
     * client.
     * 
     * @return the responseHeaderActions value.
     */
    public List responseHeaderActions() {
        return this.responseHeaderActions;
    }

    /**
     * Set the responseHeaderActions property: A list of header actions to apply from the response from AFD to the
     * client.
     * 
     * @param responseHeaderActions the responseHeaderActions value to set.
     * @return the RulesEngineAction object itself.
     */
    public RulesEngineAction withResponseHeaderActions(List responseHeaderActions) {
        this.responseHeaderActions = responseHeaderActions;
        return this;
    }

    /**
     * Get the routeConfigurationOverride property: Override the route configuration.
     * 
     * @return the routeConfigurationOverride value.
     */
    public RouteConfiguration routeConfigurationOverride() {
        return this.routeConfigurationOverride;
    }

    /**
     * Set the routeConfigurationOverride property: Override the route configuration.
     * 
     * @param routeConfigurationOverride the routeConfigurationOverride value to set.
     * @return the RulesEngineAction object itself.
     */
    public RulesEngineAction withRouteConfigurationOverride(RouteConfiguration routeConfigurationOverride) {
        this.routeConfigurationOverride = routeConfigurationOverride;
        return this;
    }

    /**
     * Validates the instance.
     * 
     * @throws IllegalArgumentException thrown if the instance is not valid.
     */
    public void validate() {
        if (requestHeaderActions() != null) {
            requestHeaderActions().forEach(e -> e.validate());
        }
        if (responseHeaderActions() != null) {
            responseHeaderActions().forEach(e -> e.validate());
        }
        if (routeConfigurationOverride() != null) {
            routeConfigurationOverride().validate();
        }
    }

    /**
     * {@inheritDoc}
     */
    @Override
    public JsonWriter toJson(JsonWriter jsonWriter) throws IOException {
        jsonWriter.writeStartObject();
        jsonWriter.writeArrayField("requestHeaderActions", this.requestHeaderActions,
            (writer, element) -> writer.writeJson(element));
        jsonWriter.writeArrayField("responseHeaderActions", this.responseHeaderActions,
            (writer, element) -> writer.writeJson(element));
        jsonWriter.writeJsonField("routeConfigurationOverride", this.routeConfigurationOverride);
        return jsonWriter.writeEndObject();
    }

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

                if ("requestHeaderActions".equals(fieldName)) {
                    List requestHeaderActions
                        = reader.readArray(reader1 -> HeaderAction.fromJson(reader1));
                    deserializedRulesEngineAction.requestHeaderActions = requestHeaderActions;
                } else if ("responseHeaderActions".equals(fieldName)) {
                    List responseHeaderActions
                        = reader.readArray(reader1 -> HeaderAction.fromJson(reader1));
                    deserializedRulesEngineAction.responseHeaderActions = responseHeaderActions;
                } else if ("routeConfigurationOverride".equals(fieldName)) {
                    deserializedRulesEngineAction.routeConfigurationOverride = RouteConfiguration.fromJson(reader);
                } else {
                    reader.skipChildren();
                }
            }

            return deserializedRulesEngineAction;
        });
    }
}




© 2015 - 2025 Weber Informatics LLC | Privacy Policy