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

com.azure.resourcemanager.frontdoor.models.RoutingRule 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.core.management.SubResource;
import com.azure.json.JsonReader;
import com.azure.json.JsonToken;
import com.azure.json.JsonWriter;
import com.azure.resourcemanager.frontdoor.fluent.models.RoutingRuleProperties;
import java.io.IOException;
import java.util.List;

/**
 * A routing rule represents a specification for traffic to treat and where to send it, along with health probe
 * information.
 */
@Fluent
public final class RoutingRule extends SubResource {
    /*
     * Properties of the Front Door Routing Rule
     */
    private RoutingRuleProperties innerProperties;

    /*
     * Resource name.
     */
    private String name;

    /*
     * Resource type.
     */
    private String type;

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

    /**
     * Get the innerProperties property: Properties of the Front Door Routing Rule.
     * 
     * @return the innerProperties value.
     */
    private RoutingRuleProperties innerProperties() {
        return this.innerProperties;
    }

    /**
     * Get the name property: Resource name.
     * 
     * @return the name value.
     */
    public String name() {
        return this.name;
    }

    /**
     * Set the name property: Resource name.
     * 
     * @param name the name value to set.
     * @return the RoutingRule object itself.
     */
    public RoutingRule withName(String name) {
        this.name = name;
        return this;
    }

    /**
     * Get the type property: Resource type.
     * 
     * @return the type value.
     */
    public String type() {
        return this.type;
    }

    /**
     * {@inheritDoc}
     */
    @Override
    public RoutingRule withId(String id) {
        super.withId(id);
        return this;
    }

    /**
     * Get the resourceState property: Resource status.
     * 
     * @return the resourceState value.
     */
    public FrontDoorResourceState resourceState() {
        return this.innerProperties() == null ? null : this.innerProperties().resourceState();
    }

    /**
     * Get the frontendEndpoints property: Frontend endpoints associated with this rule.
     * 
     * @return the frontendEndpoints value.
     */
    public List frontendEndpoints() {
        return this.innerProperties() == null ? null : this.innerProperties().frontendEndpoints();
    }

    /**
     * Set the frontendEndpoints property: Frontend endpoints associated with this rule.
     * 
     * @param frontendEndpoints the frontendEndpoints value to set.
     * @return the RoutingRule object itself.
     */
    public RoutingRule withFrontendEndpoints(List frontendEndpoints) {
        if (this.innerProperties() == null) {
            this.innerProperties = new RoutingRuleProperties();
        }
        this.innerProperties().withFrontendEndpoints(frontendEndpoints);
        return this;
    }

    /**
     * Get the acceptedProtocols property: Protocol schemes to match for this rule.
     * 
     * @return the acceptedProtocols value.
     */
    public List acceptedProtocols() {
        return this.innerProperties() == null ? null : this.innerProperties().acceptedProtocols();
    }

    /**
     * Set the acceptedProtocols property: Protocol schemes to match for this rule.
     * 
     * @param acceptedProtocols the acceptedProtocols value to set.
     * @return the RoutingRule object itself.
     */
    public RoutingRule withAcceptedProtocols(List acceptedProtocols) {
        if (this.innerProperties() == null) {
            this.innerProperties = new RoutingRuleProperties();
        }
        this.innerProperties().withAcceptedProtocols(acceptedProtocols);
        return this;
    }

    /**
     * Get the patternsToMatch property: The route patterns of the rule.
     * 
     * @return the patternsToMatch value.
     */
    public List patternsToMatch() {
        return this.innerProperties() == null ? null : this.innerProperties().patternsToMatch();
    }

    /**
     * Set the patternsToMatch property: The route patterns of the rule.
     * 
     * @param patternsToMatch the patternsToMatch value to set.
     * @return the RoutingRule object itself.
     */
    public RoutingRule withPatternsToMatch(List patternsToMatch) {
        if (this.innerProperties() == null) {
            this.innerProperties = new RoutingRuleProperties();
        }
        this.innerProperties().withPatternsToMatch(patternsToMatch);
        return this;
    }

    /**
     * Get the enabledState property: Whether to enable use of this rule. Permitted values are 'Enabled' or 'Disabled'.
     * 
     * @return the enabledState value.
     */
    public RoutingRuleEnabledState enabledState() {
        return this.innerProperties() == null ? null : this.innerProperties().enabledState();
    }

    /**
     * Set the enabledState property: Whether to enable use of this rule. Permitted values are 'Enabled' or 'Disabled'.
     * 
     * @param enabledState the enabledState value to set.
     * @return the RoutingRule object itself.
     */
    public RoutingRule withEnabledState(RoutingRuleEnabledState enabledState) {
        if (this.innerProperties() == null) {
            this.innerProperties = new RoutingRuleProperties();
        }
        this.innerProperties().withEnabledState(enabledState);
        return this;
    }

    /**
     * Get the routeConfiguration property: A reference to the routing configuration.
     * 
     * @return the routeConfiguration value.
     */
    public RouteConfiguration routeConfiguration() {
        return this.innerProperties() == null ? null : this.innerProperties().routeConfiguration();
    }

    /**
     * Set the routeConfiguration property: A reference to the routing configuration.
     * 
     * @param routeConfiguration the routeConfiguration value to set.
     * @return the RoutingRule object itself.
     */
    public RoutingRule withRouteConfiguration(RouteConfiguration routeConfiguration) {
        if (this.innerProperties() == null) {
            this.innerProperties = new RoutingRuleProperties();
        }
        this.innerProperties().withRouteConfiguration(routeConfiguration);
        return this;
    }

    /**
     * Get the rulesEngine property: A reference to a specific Rules Engine Configuration to apply to this route.
     * 
     * @return the rulesEngine value.
     */
    public SubResource rulesEngine() {
        return this.innerProperties() == null ? null : this.innerProperties().rulesEngine();
    }

    /**
     * Set the rulesEngine property: A reference to a specific Rules Engine Configuration to apply to this route.
     * 
     * @param rulesEngine the rulesEngine value to set.
     * @return the RoutingRule object itself.
     */
    public RoutingRule withRulesEngine(SubResource rulesEngine) {
        if (this.innerProperties() == null) {
            this.innerProperties = new RoutingRuleProperties();
        }
        this.innerProperties().withRulesEngine(rulesEngine);
        return this;
    }

    /**
     * Get the webApplicationFirewallPolicyLink property: Defines the Web Application Firewall policy for each routing
     * rule (if applicable).
     * 
     * @return the webApplicationFirewallPolicyLink value.
     */
    public RoutingRuleUpdateParametersWebApplicationFirewallPolicyLink webApplicationFirewallPolicyLink() {
        return this.innerProperties() == null ? null : this.innerProperties().webApplicationFirewallPolicyLink();
    }

    /**
     * Set the webApplicationFirewallPolicyLink property: Defines the Web Application Firewall policy for each routing
     * rule (if applicable).
     * 
     * @param webApplicationFirewallPolicyLink the webApplicationFirewallPolicyLink value to set.
     * @return the RoutingRule object itself.
     */
    public RoutingRule withWebApplicationFirewallPolicyLink(
        RoutingRuleUpdateParametersWebApplicationFirewallPolicyLink webApplicationFirewallPolicyLink) {
        if (this.innerProperties() == null) {
            this.innerProperties = new RoutingRuleProperties();
        }
        this.innerProperties().withWebApplicationFirewallPolicyLink(webApplicationFirewallPolicyLink);
        return this;
    }

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

    /**
     * {@inheritDoc}
     */
    @Override
    public JsonWriter toJson(JsonWriter jsonWriter) throws IOException {
        jsonWriter.writeStartObject();
        jsonWriter.writeStringField("id", id());
        jsonWriter.writeJsonField("properties", this.innerProperties);
        jsonWriter.writeStringField("name", this.name);
        return jsonWriter.writeEndObject();
    }

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

                if ("id".equals(fieldName)) {
                    deserializedRoutingRule.withId(reader.getString());
                } else if ("properties".equals(fieldName)) {
                    deserializedRoutingRule.innerProperties = RoutingRuleProperties.fromJson(reader);
                } else if ("name".equals(fieldName)) {
                    deserializedRoutingRule.name = reader.getString();
                } else if ("type".equals(fieldName)) {
                    deserializedRoutingRule.type = reader.getString();
                } else {
                    reader.skipChildren();
                }
            }

            return deserializedRoutingRule;
        });
    }
}




© 2015 - 2025 Weber Informatics LLC | Privacy Policy